don't steal focus for readonly editors

This commit is contained in:
BeniBenj
2026-03-04 23:26:04 +01:00
parent d405135f71
commit 8d491919b2

View File

@@ -342,15 +342,29 @@ export class AgentFeedbackEditorInputContribution extends Disposable implements
return;
}
// Don't capture Escape at this level - let it fall through to the input handler if focused
if (e.keyCode === KeyCode.Escape) {
this._hide();
this._editor.focus();
return;
}
// Ctrl+I / Cmd+I explicitly focuses the feedback input
if ((e.ctrlKey || e.metaKey) && e.keyCode === KeyCode.KeyI) {
e.preventDefault();
e.stopPropagation();
widget.inputElement.focus();
return;
}
// Don't focus if any modifier is held (keyboard shortcuts)
if (e.ctrlKey || e.altKey || e.metaKey) {
return;
}
// Don't capture Escape at this level - let it fall through to the input handler if focused
if (e.keyCode === KeyCode.Escape) {
this._hide();
this._editor.focus();
// Only auto-focus the input on typing when the document is readonly;
// when editable the user must click or use Ctrl+I to focus.
if (!this._editor.getOption(EditorOption.readOnly)) {
return;
}
@@ -413,6 +427,12 @@ export class AgentFeedbackEditorInputContribution extends Disposable implements
}));
}
focusInput(): void {
if (this._visible && this._widget) {
this._widget.inputElement.focus();
}
}
private _addFeedback(): boolean {
if (!this._widget) {
return false;