-
Notifications
You must be signed in to change notification settings - Fork 271
Fix recursive path handling for workspace/didChangeWatchedFiles
#1047
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I think a better approach would be to use for entry in glob::glob_with(fw.glob_pattern.as_str(), MatchOptions::default()).unwrap() {
// set watcher for entry.unwrap().display()
}
This will avoid adding watchers for the same file more than once and also adding watchers for files that the server is not interested (as I understand it, your current implementation would for example watch any extension, not only java, when given the pattern Just a side note, keep in mind that there's #1054 too, which doesn't address this issue in particular but it also involves the watcher logic. |
edfa6a2
to
196508f
Compare
Thanks for the tip, that definitely looks like a better solution. I just pushed an update that uses |
src/language_server_protocol.rs
Outdated
let mode = match path.is_dir() { | ||
true => notify::RecursiveMode::Recursive, | ||
false => notify::RecursiveMode::NonRecursive, | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clippy will complain about this, can we change it to
let mode = if path.is_dir() {
notify::RecursiveMode::Recursive
} else {
notify::RecursiveMode::NonRecursive
};
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just pushed an update to change it to use if/else
.
Oh and also, PRs should target the |
@dradtke note that you'll need to rebase this to dev, as it has some merge conflicts now (the code base has drastically changed in the last few days 😄 ). Happy to lend a hand if you need it though. |
3b57de8
to
26694f8
Compare
Just finished rebasing everything on |
@martskins Any other feedback? It'd be nice to have this PR merged in. |
Looks good to me, but it'd be nice for @autozimu to take a look, as I'm not sure I've used this feature enough to test it. |
This commit attempts to fix filesystem notifications for recursive paths that also specify an extension, such as "**/*.java".
26694f8
to
8393467
Compare
@autozimu Any thoughts on getting this PR merged in? |
Thanks for the contribution! |
This commit attempts to fix filesystem notifications for recursive paths that also specify an extension, such as "**/*.java".
Problem
LanguageClient-neovim
currently fails to register filesystem notifications for paths resembling those requested by eclipse.jdt.ls:Because none of the requested paths end with
**
, the plugin attempts to register them all as non-recursive file watches, which fails because no file named e.g.**/*.java
exists.Solution
This PR proposes a possible fix, but it's a very blunt one, and I'm open to feedback on how to make it more targeted. Specifically, if a glob pattern contains
**
anywhere, it chops off it and everything after it (defaulting to.
if it occurs at the beginning of the string, as seen above) and requests a recursive watch; otherwise, it adds a non-recursive file watch.As is, the 8 watchers requested above all end up adding a recursive
.
watch, which is inefficient. A better solution would be to register recursive watchers on.
that can still filter events by the rest of the path following**/
, but I don't know where that would be implemented.