mirror of
https://github.com/angular/angular.git
synced 2026-11-22 22:55:25 -05:00
refactor(compiler-cli): skip redundant didChange notifications in TsGoFacade
Cache the last sent document content in TsGoFacade.ensureDocument and skip sending textDocument/didChange when the content is unchanged, avoiding unnecessary cancellation of concurrent in-flight TypeScript 7 language server requests.
This commit is contained in:
committed by
Alon Mishne
parent
6d49c19e22
commit
b208470321
@@ -67,6 +67,7 @@ function normalizeLocations(
|
||||
|
||||
export class TsGoFacade {
|
||||
private documentVersions = new Map<string, number>();
|
||||
private documentContents = new Map<string, string>();
|
||||
|
||||
constructor(private connection: rpc.MessageConnection) {}
|
||||
|
||||
@@ -77,12 +78,14 @@ export class TsGoFacade {
|
||||
if (existingVersion === undefined) {
|
||||
const version = 1;
|
||||
this.documentVersions.set(uri, version);
|
||||
this.documentContents.set(uri, text);
|
||||
await this.connection.sendNotification('textDocument/didOpen', {
|
||||
textDocument: {uri, languageId: 'typescript', version, text},
|
||||
});
|
||||
} else {
|
||||
} else if (this.documentContents.get(uri) !== text) {
|
||||
const version = existingVersion + 1;
|
||||
this.documentVersions.set(uri, version);
|
||||
this.documentContents.set(uri, text);
|
||||
await this.connection.sendNotification('textDocument/didChange', {
|
||||
textDocument: {uri, version},
|
||||
contentChanges: [{text}],
|
||||
|
||||
Reference in New Issue
Block a user