From cf3d4877515aeb8a41edfe8f5dd9ba02b12d6842 Mon Sep 17 00:00:00 2001 From: Guilhem Lemouel Date: Mon, 20 Jul 2026 15:37:37 +0200 Subject: [PATCH] fix(editor): only adopt-and-overwrite a model no editor is showing Adopting an existing model at the same URI now applies this editor's content, so a model left behind by headless linting is not displayed as if it were the item. Restrict that to unattached models: one another editor is showing may hold edits the user has not saved. Co-Authored-By: Claude Opus 4.8 (1M context) --- frontend/src/lib/components/Editor.svelte | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/frontend/src/lib/components/Editor.svelte b/frontend/src/lib/components/Editor.svelte index f050c8d1f3..5827f90a8a 100644 --- a/frontend/src/lib/components/Editor.svelte +++ b/frontend/src/lib/components/Editor.svelte @@ -1347,10 +1347,11 @@ if (!nmodel) { throw err } - // Headless linting creates models at this same canonical URI, so the existing - // one can hold whatever content was last linted. Show what this editor was - // given, not that. - if (nmodel.getValue() !== (code ?? '')) { + // Headless linting creates models at this same canonical URI, so an unattached + // one holds whatever was last linted rather than this editor's content. Only + // adopt-and-overwrite in that case: a model another editor is showing may hold + // edits the user has not saved. + if (!nmodel.isAttachedToEditor() && nmodel.getValue() !== (code ?? '')) { nmodel.setValue(code ?? '') } model = nmodel