-
Notifications
You must be signed in to change notification settings - Fork 28.4k
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
API: file watching doesn't report file deletions caused by directory deletion #109754
Comments
Expected. On some platforms or for performance reasons we may decide to fold the delete event into a single one for the folder. Since you can subscribe to a pattern that includes folders as well, the workaround is to register for the folder and then check if the events match your files as children. |
I still find this a bit surprising. Doesn't that mean that the only valid GlobPattern is I might expect the file watcher to report directory deletions instead of per-file deletions when a directory was deleted, but I saw no notifications at all with a |
VS Code's file watching API doesn't send notifications about directory deletions unless you register for them explicitly (see microsoft/vscode#109754). Rather than watch every file in the workspace, keep track of every relevant directory and register file watchers for it. This CL moves the snapshot's WorkspaceDirectories function to the session and changes it to a KnownDirectories function. It returns all of the directories and subdirectories known the session at a given moment. Top-level directories are marked as such so that their *.{go,mod,sum} contents can be watched, while subdirectories are just watched by path so we can be notified of deletions. Fixes golang/go#42348 Change-Id: If80a26cf6af5a2c2f7d87bb57b9ef5cb3dcf04ac Reviewed-on: https://go-review.googlesource.com/c/tools/+/267120 Trust: Rebecca Stambler <rstambler@golang.org> Run-TryBot: Rebecca Stambler <rstambler@golang.org> gopls-CI: kokoro <noreply+kokoro@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Heschi Kreinick <heschi@google.com>
VS Code's file watching API doesn't send notifications about directory deletions unless you register for them explicitly (see microsoft/vscode#109754). Rather than watch every file in the workspace, keep track of every relevant directory and register file watchers for it. This CL moves the snapshot's WorkspaceDirectories function to the session and changes it to a KnownDirectories function. It returns all of the directories and subdirectories known the session at a given moment. Top-level directories are marked as such so that their *.{go,mod,sum} contents can be watched, while subdirectories are just watched by path so we can be notified of deletions. Fixes golang/go#42348 Change-Id: Ic6d02dba55b5de89370522ea5d3cf1d198927997 Reviewed-on: https://go-review.googlesource.com/c/tools/+/271438 Run-TryBot: Rebecca Stambler <rstambler@golang.org> gopls-CI: kokoro <noreply+kokoro@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Heschi Kreinick <heschi@google.com> Trust: Rebecca Stambler <rstambler@golang.org>
In the Go language server, we register a file watcher with a
GlobPattern
of"**/*.{go,mod,sum}"
. I would expect that this file watcher would report deletions of files caused by the deletion of a directory, but this doesn't seem to be the case.For example, if the workspace contains a directory
foo
with the filefoo.go
, deletingfoo
either in the terminal (rm -rf foo
) or in the VS Code UI does not result in any change notifications forfoo/foo.go
. The only way I was able to get notifications was when I registered a watcher with theGlobPattern
of"**"
, but we'd prefer to avoid registering for notifications for all files in the workspace.Is this expected behavior or have we made some mistake here?
VSCode Version:
1.51.0-insider
2ee8b8c
x64
OS Version: Mac OS Catalina 10.15.7
The text was updated successfully, but these errors were encountered: