-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
createFileSystemWatcher API not fired when parents renamed #60813
Comments
(Experimental duplicate detection) |
This is a consequence of us optimizing to only report the folder rename as a change event and not the files within. We might support this scenario with a new file system implementation. |
Interesting choice. Should I change my bits to use the onChange method? |
@NTaylorMullen well there is currently no workaround unless you throw in a glob pattern with the name of the folder that was renamed. |
Oh geez that's pretty bad. I guess we'll have to leave the behavior broken for now then. Is there another issue I can watch that tracks the effort to "support this scenario with a new file system implementation"? |
We closed this issue because we don't plan to address it in the foreseeable future. You can find more detailed information about our decision-making process here. If you disagree and feel that this issue is crucial: We are happy to listen and to reconsider. If you wonder what we are up to, please see our roadmap and issue reporting guidelines. Thanks for your understanding and happy coding! |
Is this API completely broken then? If I'm writing a C extension (for example) and a user opens |
This is a pretty big limitation for stateful language servers which cannot track project-wide diagnostics and changes - it's almost 3 years old, anyone using some workarounds (except for custom language client and filewatcher)?
Theoretically, this could work by throwing in the glob all existing folders, but once there is some folder for example copied (as it was not existing), then the server is unnotified again. |
I have used the glob pattern "**/*" which is triggering didChangeWatchedFile for each folder delete or rename(in this case created and deleted). In case of copying a folder, the didChangeWatchedFile event is triggered for folder creation, and for all the nested specific files for which patterns are registered. |
…d / deleted (microsoft#157956) Fix markdown link diagnostics not updated when directories are renamed/deleted Turns our that `createFileSystemWatcher` will not fire if a parent dir is renamed / deleted. See microsoft#60813 To fix this, I believe we have to create watchers for all parent directories too (or watch everything in the entire workspace)
I've found this is a problem when trying to watch file changes in PHP projects when using composer. Composer appears to save files to a temp directory before renaming the dir. This results in a bunch of create events for files that only exist briefly and no events for the rename. |
Not gonna lie, I 'm having a hard time understanding why the file watching API is so broken here. If I set up a file watcher, I expect:
In reality, you only get events when a "file" has the first three happen to it. Meaning if a "file" is deleted because a folder is deleted, you are not alerted which indicates that you are, in fact, not actually watching the files.
|
I still don't understand how we're supposed to use this API at all given this bug. Suppose I'm writing an LSP for Java. I want to know about all It sounds like the only way to do that currently is:
Ironically the LSP specification recommends using this API because:
Well, yeah. Can you really say "use our API - it's hard to get it right", when your API is so fundamentally broken? |
I have this problem with renamed or deleted folders for a language client I'm working on. I didn't find a workaround yet. I tried adding server capabilities for "workspace" and that didn't help. |
I ended up doing two things: |
Steps to Reproduce:
Expected: remove => create gets called on the watched files
Actual: Nothing fires
Additional Notes
Seeing this in practice in the Razor VSCode extension: https://github.com/aspnet/Razor.VSCode/blob/05b60813dd446fc4a21529a3513aeec186886465/src/Microsoft.AspNetCore.Razor.VSCode/src/RazorProjectTracker.ts#L25-L32
The text was updated successfully, but these errors were encountered: