Skip to content

Commit c26e05c

Browse files
committed
Don't watch in-memory resources
Fixes microsoft#221583
1 parent 6f2764a commit c26e05c

File tree

1 file changed

+32
-26
lines changed

1 file changed

+32
-26
lines changed

extensions/typescript-language-features/src/typescriptServiceClient.ts

+32-26
Original file line numberDiff line numberDiff line change
@@ -972,81 +972,91 @@ export default class TypeScriptServiceClient extends Disposable implements IType
972972
spans: diagnosticEvent.body.spans,
973973
});
974974
}
975-
break;
975+
return;
976976
}
977977
case EventName.configFileDiag:
978978
this._onConfigDiagnosticsReceived.fire(event as Proto.ConfigFileDiagnosticEvent);
979-
break;
979+
return;
980980

981981
case EventName.telemetry: {
982982
const body = (event as Proto.TelemetryEvent).body;
983983
this.dispatchTelemetryEvent(body);
984-
break;
984+
return;
985985
}
986986
case EventName.projectLanguageServiceState: {
987987
const body = (event as Proto.ProjectLanguageServiceStateEvent).body!;
988988
if (this.serverState.type === ServerState.Type.Running) {
989989
this.serverState.updateLanguageServiceEnabled(body.languageServiceEnabled);
990990
}
991991
this._onProjectLanguageServiceStateChanged.fire(body);
992-
break;
992+
return;
993993
}
994994
case EventName.projectsUpdatedInBackground: {
995995
this.loadingIndicator.reset();
996996

997997
const body = (event as Proto.ProjectsUpdatedInBackgroundEvent).body;
998998
const resources = body.openFiles.map(file => this.toResource(file));
999999
this.bufferSyncSupport.getErr(resources);
1000-
break;
1000+
return;
10011001
}
10021002
case EventName.beginInstallTypes:
10031003
this._onDidBeginInstallTypings.fire((event as Proto.BeginInstallTypesEvent).body);
1004-
break;
1004+
return;
10051005

10061006
case EventName.endInstallTypes:
10071007
this._onDidEndInstallTypings.fire((event as Proto.EndInstallTypesEvent).body);
1008-
break;
1008+
return;
10091009

10101010
case EventName.typesInstallerInitializationFailed:
10111011
this._onTypesInstallerInitializationFailed.fire((event as Proto.TypesInstallerInitializationFailedEvent).body);
1012-
break;
1012+
return;
10131013

10141014
case EventName.surveyReady:
10151015
this._onSurveyReady.fire((event as Proto.SurveyReadyEvent).body);
1016-
break;
1016+
return;
10171017

10181018
case EventName.projectLoadingStart:
10191019
this.loadingIndicator.startedLoadingProject((event as Proto.ProjectLoadingStartEvent).body.projectName);
1020-
break;
1020+
return;
10211021

10221022
case EventName.projectLoadingFinish:
10231023
this.loadingIndicator.finishedLoadingProject((event as Proto.ProjectLoadingFinishEvent).body.projectName);
1024-
break;
1024+
return;
1025+
1026+
case EventName.createDirectoryWatcher: {
1027+
const path = (event.body as Proto.CreateDirectoryWatcherEventBody).path;
1028+
if (path.startsWith(inMemoryResourcePrefix)) {
1029+
return;
1030+
}
10251031

1026-
case EventName.createDirectoryWatcher:
10271032
this.createFileSystemWatcher(
10281033
(event.body as Proto.CreateDirectoryWatcherEventBody).id,
10291034
new vscode.RelativePattern(
1030-
vscode.Uri.file((event.body as Proto.CreateDirectoryWatcherEventBody).path),
1035+
vscode.Uri.file(path),
10311036
(event.body as Proto.CreateDirectoryWatcherEventBody).recursive ? '**' : '*'
10321037
),
10331038
(event.body as Proto.CreateDirectoryWatcherEventBody).ignoreUpdate
10341039
);
1035-
break;
1040+
return;
1041+
}
1042+
case EventName.createFileWatcher: {
1043+
const path = (event.body as Proto.CreateFileWatcherEventBody).path;
1044+
if (path.startsWith(inMemoryResourcePrefix)) {
1045+
return;
1046+
}
10361047

1037-
case EventName.createFileWatcher:
10381048
this.createFileSystemWatcher(
10391049
(event.body as Proto.CreateFileWatcherEventBody).id,
10401050
new vscode.RelativePattern(
1041-
vscode.Uri.file((event.body as Proto.CreateFileWatcherEventBody).path),
1051+
vscode.Uri.file(path),
10421052
'*'
10431053
)
10441054
);
1045-
break;
1046-
1055+
return;
1056+
}
10471057
case EventName.closeFileWatcher:
10481058
this.closeFileSystemWatcher(event.body.id);
1049-
break;
1059+
return;
10501060

10511061
case EventName.requestCompleted: {
10521062
// @ts-expect-error until ts 5.6
@@ -1063,7 +1073,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType
10631073
})
10641074
);
10651075
}
1066-
break;
1076+
return;
10671077
}
10681078
}
10691079
}
@@ -1148,13 +1158,9 @@ export default class TypeScriptServiceClient extends Disposable implements IType
11481158
this.watches.set(id, disposable);
11491159
}
11501160

1151-
private closeFileSystemWatcher(
1152-
id: number,
1153-
) {
1161+
private closeFileSystemWatcher(id: number) {
11541162
const existing = this.watches.get(id);
1155-
if (existing) {
1156-
existing.dispose();
1157-
}
1163+
existing?.dispose();
11581164
}
11591165

11601166
private dispatchTelemetryEvent(telemetryData: Proto.TelemetryEventBody): void {

0 commit comments

Comments
 (0)