From fe6e221be4e4b7adb0c630c05d2f9c54d8ec00fd Mon Sep 17 00:00:00 2001 From: Alexandru Dima Date: Mon, 24 Mar 2025 12:00:53 +0100 Subject: [PATCH] Fix problem where the editor would not emit a focus loss event when the model would be cleared (#244443) --- .../browser/widget/codeEditor/codeEditorWidget.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/vs/editor/browser/widget/codeEditor/codeEditorWidget.ts b/src/vs/editor/browser/widget/codeEditor/codeEditorWidget.ts index 042152e7dde..fc0a05c5ede 100644 --- a/src/vs/editor/browser/widget/codeEditor/codeEditorWidget.ts +++ b/src/vs/editor/browser/widget/codeEditor/codeEditorWidget.ts @@ -498,8 +498,16 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE const hasTextFocus = this.hasTextFocus(); const detachedModel = this._detachModel(); this._attachModel(model); - if (hasTextFocus && this.hasModel()) { - this.focus(); + if (this.hasModel()) { + // we have a new model (with a new view)! + if (hasTextFocus) { + this.focus(); + } + } else { + // we have no model (and no view) anymore + // make sure the outside world knows we are not focused + this._editorTextFocus.setValue(false); + this._editorWidgetFocus.setValue(false); } this._removeDecorationTypes();