From b488ab464f1d2a966954adc7bd87c9dac2015280 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Thu, 29 Jan 2026 14:20:25 +0000 Subject: [PATCH] Fix command palette auto-close when focus was in inline chat (#291560) * Initial plan * Fix command palette auto-close when focus was in inline chat Move editor focus logic from InlineChatAffordance into InlineChatInputWidget._hide() and only focus editor when focus is still within the editor's DOM. This prevents stealing focus from command palette when it opens. Co-authored-by: jrieken <1794099+jrieken@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: jrieken <1794099+jrieken@users.noreply.github.com> --- .../contrib/inlineChat/browser/inlineChatAffordance.ts | 1 - .../contrib/inlineChat/browser/inlineChatOverlayWidget.ts | 5 +++++ 2 files changed, 5 insertions(+), 1 deletion(-) 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(); }