From b20847032130611ffaf89dd7ab8d7aec2e90d5a6 Mon Sep 17 00:00:00 2001 From: Andrew Scott Date: Wed, 11 Nov 2026 16:59:32 -0800 Subject: [PATCH] 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. --- .../compiler-cli/preprocessor/language-service/src/facade.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/compiler-cli/preprocessor/language-service/src/facade.ts b/packages/compiler-cli/preprocessor/language-service/src/facade.ts index abbbb8910b0..b7cf2859653 100644 --- a/packages/compiler-cli/preprocessor/language-service/src/facade.ts +++ b/packages/compiler-cli/preprocessor/language-service/src/facade.ts @@ -67,6 +67,7 @@ function normalizeLocations( export class TsGoFacade { private documentVersions = new Map(); + private documentContents = new Map(); 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}],