Don't watch in-memory resources (#224535)

Fixes #221583
This commit is contained in:
Matt Bierner
2024-08-01 17:22:31 -07:00
committed by GitHub
parent d00533a1df
commit fd5f15a2b3

View File

@@ -972,16 +972,16 @@ export default class TypeScriptServiceClient extends Disposable implements IType
spans: diagnosticEvent.body.spans,
});
}
break;
return;
}
case EventName.configFileDiag:
this._onConfigDiagnosticsReceived.fire(event as Proto.ConfigFileDiagnosticEvent);
break;
return;
case EventName.telemetry: {
const body = (event as Proto.TelemetryEvent).body;
this.dispatchTelemetryEvent(body);
break;
return;
}
case EventName.projectLanguageServiceState: {
const body = (event as Proto.ProjectLanguageServiceStateEvent).body!;
@@ -989,7 +989,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType
this.serverState.updateLanguageServiceEnabled(body.languageServiceEnabled);
}
this._onProjectLanguageServiceStateChanged.fire(body);
break;
return;
}
case EventName.projectsUpdatedInBackground: {
this.loadingIndicator.reset();
@@ -997,56 +997,66 @@ export default class TypeScriptServiceClient extends Disposable implements IType
const body = (event as Proto.ProjectsUpdatedInBackgroundEvent).body;
const resources = body.openFiles.map(file => this.toResource(file));
this.bufferSyncSupport.getErr(resources);
break;
return;
}
case EventName.beginInstallTypes:
this._onDidBeginInstallTypings.fire((event as Proto.BeginInstallTypesEvent).body);
break;
return;
case EventName.endInstallTypes:
this._onDidEndInstallTypings.fire((event as Proto.EndInstallTypesEvent).body);
break;
return;
case EventName.typesInstallerInitializationFailed:
this._onTypesInstallerInitializationFailed.fire((event as Proto.TypesInstallerInitializationFailedEvent).body);
break;
return;
case EventName.surveyReady:
this._onSurveyReady.fire((event as Proto.SurveyReadyEvent).body);
break;
return;
case EventName.projectLoadingStart:
this.loadingIndicator.startedLoadingProject((event as Proto.ProjectLoadingStartEvent).body.projectName);
break;
return;
case EventName.projectLoadingFinish:
this.loadingIndicator.finishedLoadingProject((event as Proto.ProjectLoadingFinishEvent).body.projectName);
break;
return;
case EventName.createDirectoryWatcher: {
const path = (event.body as Proto.CreateDirectoryWatcherEventBody).path;
if (path.startsWith(inMemoryResourcePrefix)) {
return;
}
case EventName.createDirectoryWatcher:
this.createFileSystemWatcher(
(event.body as Proto.CreateDirectoryWatcherEventBody).id,
new vscode.RelativePattern(
vscode.Uri.file((event.body as Proto.CreateDirectoryWatcherEventBody).path),
vscode.Uri.file(path),
(event.body as Proto.CreateDirectoryWatcherEventBody).recursive ? '**' : '*'
),
(event.body as Proto.CreateDirectoryWatcherEventBody).ignoreUpdate
);
break;
return;
}
case EventName.createFileWatcher: {
const path = (event.body as Proto.CreateFileWatcherEventBody).path;
if (path.startsWith(inMemoryResourcePrefix)) {
return;
}
case EventName.createFileWatcher:
this.createFileSystemWatcher(
(event.body as Proto.CreateFileWatcherEventBody).id,
new vscode.RelativePattern(
vscode.Uri.file((event.body as Proto.CreateFileWatcherEventBody).path),
vscode.Uri.file(path),
'*'
)
);
break;
return;
}
case EventName.closeFileWatcher:
this.closeFileSystemWatcher(event.body.id);
break;
return;
case EventName.requestCompleted: {
// @ts-expect-error until ts 5.6
@@ -1063,7 +1073,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType
})
);
}
break;
return;
}
}
}
@@ -1148,13 +1158,9 @@ export default class TypeScriptServiceClient extends Disposable implements IType
this.watches.set(id, disposable);
}
private closeFileSystemWatcher(
id: number,
) {
private closeFileSystemWatcher(id: number) {
const existing = this.watches.get(id);
if (existing) {
existing.dispose();
}
existing?.dispose();
}
private dispatchTelemetryEvent(telemetryData: Proto.TelemetryEventBody): void {