From 16d8ecdb8ff696c06daa4b7db975357a3af10e5f Mon Sep 17 00:00:00 2001 From: Milan Bhandari Date: Mon, 12 Oct 2026 12:02:06 -0500 Subject: [PATCH] Make diffr-web's file models plain text without a language selection Each model was created with a plain-text language selection, which subscribes it to the language service. A large comparison's ~430 models tripped the emitter's leak check, raised as uncaught errors at 200, 300 and 400 listeners. The models never change language, since diffr's decorations colour the code, so they now take plain text directly. Agent-Session: 429958d8-68f3-4f68-bd3b-a8371e7feb8e Agent-Session: 5eb4067a-b2f6-4508-a6dd-0471ff2c14d1 --- .../src/review/services/reviewFilesDiffView.ts | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/apps/diffr-web/src/review/services/reviewFilesDiffView.ts b/apps/diffr-web/src/review/services/reviewFilesDiffView.ts index 596fbe791..ee9695122 100644 --- a/apps/diffr-web/src/review/services/reviewFilesDiffView.ts +++ b/apps/diffr-web/src/review/services/reviewFilesDiffView.ts @@ -49,8 +49,6 @@ import { IDiffEditorOptions, } from "vs/editor/common/config/editorOptions.js"; import { Range } from "vs/editor/common/core/range.js"; -import { ILanguageService } from "vs/editor/common/languages/language.js"; -import { PLAINTEXT_LANGUAGE_ID } from "vs/editor/common/languages/modesRegistry.js"; import { IModelService } from "vs/editor/common/services/model.js"; import { IHoverService } from "vs/platform/hover/browser/hover.js"; import { IInstantiationService } from "vs/platform/instantiation/common/instantiation.js"; @@ -138,7 +136,6 @@ export class ReviewFilesEditorInput extends Disposable { /** Whether long lines wrap, in every file. */ private readonly wordWrap: IObservable, @IModelService private readonly modelService: IModelService, - @ILanguageService private readonly languageService: ILanguageService, @IInstantiationService private readonly instantiationService: IInstantiationService, ) { @@ -181,14 +178,12 @@ export class ReviewFilesEditorInput extends Disposable { const diff = this.session.getFileResult(entry.file.path)?.diff; if (!diff) return undefined; const store = new DisposableStore(); + // Plain text without a language selection: diffr's decorations colour the code, and a + // selection would subscribe every model to the language service. const model = (uri: URI, text: string) => store.add( this.modelService.getModel(uri) ?? - this.modelService.createModel( - text, - this.languageService.createById(PLAINTEXT_LANGUAGE_ID), - uri, - ), + this.modelService.createModel(text, null, uri), ); const text = (side: "lhs" | "rhs") => diff.type === "text" ? (diff[side]?.text ?? "") : "";