1+ import { FSWatcher , watch as chokidarWatch } from 'chokidar' ;
12import * as child_process from "node:child_process" ;
23import * as path from "path" ;
34import { 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