microsoft / vscode-languageserver-node

Language server protocol implementation for VSCode. This allows implementing language services in JS/TS running on node.js
MIT License
1.45k stars 325 forks source link

Tracking deleted files from a folder which is deleted #1317

Open angelozerr opened 1 year ago

angelozerr commented 1 year ago

We have a language server which need to track deleted files (//*.html files) To do that we use workspace/didChangeWatchedFiles which is working great when user delete html files.

The problem comes from when a folder which contains html files are deleted.

My first question is it an expected behavior (I mean a different behavior between 2 OS) ?

I discover the workspace/didDeleteFiles notification, what is the difference from the workspace/didChangeWatchedFiles

Many thanks for your clarification!

rgrunber commented 1 year ago

According to https://github.com/microsoft/vscode-languageserver-node/issues/141#issuecomment-271296153 , the behaviour should be to only notify that the folder has been deleted in all cases. So this has regressed now it seems. The language client should try to protect against inconsistent behaviour across different platforms.

dbaeumer commented 1 year ago

@bpasero I get these events 1:1 from VS Code. Is this expected?

bpasero commented 1 year ago

Yes, it is expected that we do not send out delete events for each entry of a folder because listeners can easily figure out if a path is a child of said path and we can reduce the amount of events we have to send around:

https://github.com/microsoft/vscode/blob/d932af32771f4fcb8bef171f3114dfbd06ec5bed/src/vs/platform/files/common/watcher.ts#L377-L403

However, we rely on the operating system to give us the actual file events and our normalization of events works by accumulating events over some short period. If the OS gives us events slowly, above the threshold, we might start to send out individual deletes because we cannot find a common ancestor.

File events can be logged when you run code --verbose and look for [File Watcher (parcel)] entries in the developer tools console:

image

michprev commented 2 months ago

I am receiving no event(s) at all after deleting a directory containing *.sol file(s) with the watchdog configured as:

FileSystemWatcher(
    glob_pattern="**/*.sol",
    kind=None,
),

Is this an expected behavior?

My VS Code setup:

Version: 1.90.2
Commit: 5437499feb04f7a586f677b155b039bc2b3669eb
Date: 2024-06-18T22:54:35.075Z
Electron: 29.4.0
ElectronBuildId: 9728852
Chromium: 122.0.6261.156
Node.js: 20.9.0
V8: 12.2.281.27-electron.0
OS: Darwin arm64 23.5.0
dbaeumer commented 2 months ago

As @bpasero pointed out we only send out events for the folder when a folder gets deleted. So you need to register for folder deletions as well.