Skip to content

Commit 82e9a75

Browse files
committed
Invoked should be property on watchers map instead of local variable since watchers arent closed if they need to be reopened
1 parent 60b19f5 commit 82e9a75

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/server/typingsInstaller/typingsInstaller.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,13 @@ namespace ts.server.typingsInstaller {
6464
onRequestCompleted: RequestCompletedAction;
6565
}
6666

67+
type ProjectWatchers = Map<FileWatcher> & { isInvoked?: boolean; };
68+
6769
export abstract class TypingsInstaller {
6870
private readonly packageNameToTypingLocation: Map<JsTyping.CachedTyping> = createMap<JsTyping.CachedTyping>();
6971
private readonly missingTypingsSet: Map<true> = createMap<true>();
7072
private readonly knownCachesSet: Map<true> = createMap<true>();
71-
private readonly projectWatchers = createMap<Map<FileWatcher>>();
73+
private readonly projectWatchers = createMap<ProjectWatchers>();
7274
private safeList: JsTyping.SafeList | undefined;
7375
readonly pendingRunRequests: PendingRequest[] = [];
7476

@@ -378,8 +380,8 @@ namespace ts.server.typingsInstaller {
378380
this.projectWatchers.set(projectName, watchers);
379381
}
380382

383+
watchers.isInvoked = false;
381384
// handler should be invoked once for the entire set of files since it will trigger full rediscovery of typings
382-
let isInvoked = false;
383385
const isLoggingEnabled = this.log.isEnabled();
384386
mutateMap(
385387
watchers,
@@ -392,11 +394,11 @@ namespace ts.server.typingsInstaller {
392394
}
393395
const watcher = this.installTypingHost.watchFile(file, (f, eventKind) => {
394396
if (isLoggingEnabled) {
395-
this.log.writeLine(`FileWatcher:: Triggered with ${f} eventKind: ${FileWatcherEventKind[eventKind]}:: WatchInfo: ${file}:: handler is already invoked '${isInvoked}'`);
397+
this.log.writeLine(`FileWatcher:: Triggered with ${f} eventKind: ${FileWatcherEventKind[eventKind]}:: WatchInfo: ${file}:: handler is already invoked '${watchers.isInvoked}'`);
396398
}
397-
if (!isInvoked) {
399+
if (!watchers.isInvoked) {
400+
watchers.isInvoked = true;
398401
this.sendResponse({ projectName, kind: ActionInvalidate });
399-
isInvoked = true;
400402
}
401403
}, /*pollingInterval*/ 2000);
402404
return isLoggingEnabled ? {

0 commit comments

Comments
 (0)