zellij icon indicating copy to clipboard operation
zellij copied to clipboard

Modify watch_filesystem to take in a list of folders to watch

Open leakec opened this issue 1 year ago • 1 comments

It would be nice to modify watch_filesystem to take in a list of folders to watch. The reasons for doing this are:

  1. Avoid doing unnecessary work watching files we don't care about.
  2. Currently, this watches the /host folder and recurses through all child folders. As a result, if the user doesn't have access to a file in the /host folder or child folders, this results in an error. Restricting the folders watched to the minimum required should limit this happening.

To make this change, watch_filesystem could be modified from this function signature

pub fn watch_filesystem()

to

pub fn watch_filesystem(files: &HashMap<PathBuf, bool>)

If watch_filesystem is called with an empty HashMap, we can fill it with /host and true to get the previous behavior.

The downside of this is the function signature of watch_filesystem will change, which means any plugins using it will need to update this call. This doesn't seem to be used much in the zellij core. There was only one instance of it in the core, and it was for a test. multitask is another plugin I know that uses this, and I will update said plugin if this change is made.

I've got this implemented and tested on a local fork. Would be happy to submit a PR if this is accepted (or modify and submit a PR based on any discussion here).

leakec avatar May 04 '24 19:05 leakec

The PR I have ready for this is located here (should have added this when I first opened the issue).

EDIT: Created PR at #3377.

leakec avatar May 22 '24 15:05 leakec

Closing this as the PR has been closed. There is a better way to fix this, which is with new plugin APIs available in 0.41! :)

leakec avatar Nov 05 '24 15:11 leakec