Repository navigation
Closed
Description
I was updating some code of ours that uses LSP to register file watching dynamically, and was curious what the expected contract is if you register a new set of file watches with the same ID as the previous set of watches: does it give an error (the ID should be unique) or does it update the registration with the new list? It turns out the implementation (linked below) does accept the registration, and will create new watches, but still assumes the ID was unique, and will leak the previous disposables. This appears to be a bug.
The LSP spec seems silent on whether dynamic updates like this are allowed or not.
vscode-languageserver-node/client/src/common/fileSystemWatcher.ts
Lines 48 to 69 in 2d17738
| public register(data: RegistrationData<DidChangeWatchedFilesRegistrationOptions>): void { | |
| if (!Array.isArray(data.registerOptions.watchers)) { | |
| return; | |
| } | |
| const disposables: Disposable[] = []; | |
| for (const watcher of data.registerOptions.watchers) { | |
| const globPattern = this._client.protocol2CodeConverter.asGlobPattern(watcher.globPattern); | |
| if (globPattern === undefined) { | |
| continue; | |
| } | |
| let watchCreate: boolean = true, watchChange: boolean = true, watchDelete: boolean = true; | |
| if (watcher.kind !== undefined && watcher.kind !== null) { | |
| watchCreate = (watcher.kind & WatchKind.Create) !== 0; | |
| watchChange = (watcher.kind & WatchKind.Change) !== 0; | |
| watchDelete = (watcher.kind & WatchKind.Delete) !== 0; | |
| } | |
| const fileSystemWatcher: VFileSystemWatcher = Workspace.createFileSystemWatcher(globPattern, !watchCreate, !watchChange, !watchDelete); | |
| this.hookListeners(fileSystemWatcher, watchCreate, watchChange, watchDelete, disposables); | |
| disposables.push(fileSystemWatcher); | |
| } | |
| this._watchers.set(data.id, disposables); | |
| } |
Metadata
Metadata
Assignees
Labels
No labels
Activity