Skip to content

Commit eeae075

Browse files
committed
Use chokidar instead
1 parent e4d4d1c commit eeae075

File tree

3 files changed

+41
-11
lines changed

3 files changed

+41
-11
lines changed

lldb/tools/lldb-dap/package-lock.json

Lines changed: 31 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lldb/tools/lldb-dap/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
"categories": [
2828
"Debuggers"
2929
],
30+
"dependencies": {
31+
"chokidar": "^4.0.3"
32+
},
3033
"devDependencies": {
3134
"@types/node": "^18.19.41",
3235
"@types/tabulator-tables": "^6.2.10",

lldb/tools/lldb-dap/src-ts/lldb-dap-server.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { FSWatcher, watch as chokidarWatch } from 'chokidar';
12
import * as child_process from "node:child_process";
23
import * as path from "path";
34
import { isDeepStrictEqual } from "util";
@@ -14,7 +15,7 @@ export class LLDBDapServer implements vscode.Disposable {
1415
private serverInfo?: Promise<{ host: string; port: number }>;
1516
private serverSpawnInfo?: string[];
1617
// Detects changes to the lldb-dap executable file since the server's startup.
17-
private serverFileWatcher?: vscode.FileSystemWatcher;
18+
private serverFileWatcher?: FSWatcher;
1819
// Indicates whether the lldb-dap executable file has changed since the server's startup.
1920
private serverFileChanged?: boolean;
2021

@@ -91,15 +92,10 @@ export class LLDBDapServer implements vscode.Disposable {
9192
this.serverFileChanged = false;
9293
// Cannot do `createFileSystemWatcher(dapPath)` for a single file. Have to use `RelativePattern`.
9394
// See https://github.com/microsoft/vscode/issues/141011#issuecomment-1016772527
94-
this.serverFileWatcher = vscode.workspace.createFileSystemWatcher(
95-
new vscode.RelativePattern(
96-
vscode.Uri.file(path.dirname(dapPath)),
97-
path.basename(dapPath),
98-
),
99-
);
100-
this.serverFileWatcher.onDidChange(() => {
101-
this.serverFileChanged = true;
102-
});
95+
this.serverFileWatcher = chokidarWatch(dapPath);
96+
this.serverFileWatcher
97+
.on('change', () => this.serverFileChanged = true)
98+
.on('unlink', () => this.serverFileChanged = true);
10399
});
104100
return this.serverInfo;
105101
}
@@ -204,7 +200,7 @@ Restarting the server will interrupt any existing debug sessions and start a new
204200
this.serverProcess = undefined;
205201
this.serverInfo = undefined;
206202
this.serverSpawnInfo = undefined;
207-
this.serverFileWatcher?.dispose();
203+
this.serverFileWatcher?.close();
208204
this.serverFileWatcher = undefined;
209205
this.serverFileChanged = undefined;
210206
}

0 commit comments

Comments
 (0)