diff --git a/src/vs/workbench/contrib/inlineChat/browser/inlineChatAffordance.ts b/src/vs/workbench/contrib/inlineChat/browser/inlineChatAffordance.ts index f0ec896f0bb..58db6c0bd36 100644 --- a/src/vs/workbench/contrib/inlineChat/browser/inlineChatAffordance.ts +++ b/src/vs/workbench/contrib/inlineChat/browser/inlineChatAffordance.ts @@ -111,7 +111,6 @@ export class InlineChatAffordance extends Disposable { const pos = this._inputWidget.position.read(r); if (pos === null) { this._menuData.set(undefined, undefined); - this._editor.focus(); } })); } diff --git a/src/vs/workbench/contrib/inlineChat/browser/inlineChatOverlayWidget.ts b/src/vs/workbench/contrib/inlineChat/browser/inlineChatOverlayWidget.ts index 5094ab2e70d..0284206c2bf 100644 --- a/src/vs/workbench/contrib/inlineChat/browser/inlineChatOverlayWidget.ts +++ b/src/vs/workbench/contrib/inlineChat/browser/inlineChatOverlayWidget.ts @@ -278,6 +278,11 @@ export class InlineChatInputWidget extends Disposable { * Hide the widget (removes from editor but does not dispose). */ private _hide(): void { + // Focus editor if focus is still within the editor's DOM + const editorDomNode = this._editorObs.editor.getDomNode(); + if (editorDomNode && dom.isAncestorOfActiveElement(editorDomNode)) { + this._editorObs.editor.focus(); + } this._position.set(null, undefined); this._showStore.clear(); }