Skip to content

Commit 1444434

Browse files
authored
Removing the forceful focus on editor when triggering AI action from AI lightbulb menu (microsoft#199378)
* adding the message * doing an early return and calling prevent default only when command is executed
1 parent 506f72a commit 1444434

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/vs/editor/contrib/codeAction/browser/lightBulbWidget.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,6 @@ export class LightBulbWidget extends Disposable implements IContentWidget {
8585
if (this.state.type !== LightBulbState.Type.Showing) {
8686
return;
8787
}
88-
const focusEditor = () => {
89-
this._editor.focus();
90-
e.preventDefault();
91-
};
9288

9389
const option = this._editor.getOption(EditorOption.lightbulb).experimental.showAiIcon;
9490
if (
@@ -99,12 +95,14 @@ export class LightBulbWidget extends Disposable implements IContentWidget {
9995
const action = this.state.actions.validActions[0].action;
10096
if (action.command?.id) {
10197
commandService.executeCommand(action.command.id, ...(action.command.arguments || []));
98+
e.preventDefault();
99+
return;
102100
}
103-
focusEditor();
104-
return;
105101
}
106102
// Make sure that focus / cursor location is not lost when clicking widget icon
107-
focusEditor();
103+
this._editor.focus();
104+
e.preventDefault();
105+
108106
// a bit of extra work to make sure the menu
109107
// doesn't cover the line-text
110108
const { top, height } = dom.getDomNodePagePosition(this._domNode);

0 commit comments

Comments
 (0)