Skip to content

Commit d81f78f

Browse files
Only unset editor if we are swapping models and not on hide (#17065)
Fixes #17064
1 parent 1d799cd commit d81f78f

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

packages/plugin-ext/src/main/browser/text-editor-main.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,16 @@ export class TextEditorMain implements Disposable {
9595
this.toDisposeOnEditor.push(this.editor.onSelectionChanged(_ => {
9696
this.updateProperties();
9797
}));
98-
this.toDisposeOnEditor.push(monacoEditor.onDidChangeModel(() => {
99-
this.setEditor(undefined);
98+
this.toDisposeOnEditor.push(monacoEditor.onDidChangeModel(e => {
99+
// Ignore visibility-related model changes (null ↔ model) triggered by
100+
// the setModel(null) workaround in MonacoEditor.handleVisibilityChanged().
101+
// cf. https://github.com/eclipse-theia/theia/issues/14880
102+
// Only react to genuine model swaps where both old and new models exist.
103+
// In practice, this condition is never met because MonacoEditor instances
104+
// are created with a fixed document and never swap to a different model.
105+
if (e.oldModelUrl && e.newModelUrl) {
106+
this.setEditor(undefined);
107+
}
100108
}));
101109
this.toDisposeOnEditor.push(monacoEditor.onDidChangeCursorSelection(e => {
102110
this.updateProperties(e.source);

0 commit comments

Comments
 (0)