Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing the forceful focus on editor when triggering AI action from AI lightbulb menu #199378

Merged
merged 2 commits into from
Nov 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 5 additions & 7 deletions src/vs/editor/contrib/codeAction/browser/lightBulbWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,6 @@ export class LightBulbWidget extends Disposable implements IContentWidget {
if (this.state.type !== LightBulbState.Type.Showing) {
return;
}
const focusEditor = () => {
this._editor.focus();
e.preventDefault();
};

const option = this._editor.getOption(EditorOption.lightbulb).experimental.showAiIcon;
if (
Expand All @@ -99,12 +95,14 @@ export class LightBulbWidget extends Disposable implements IContentWidget {
const action = this.state.actions.validActions[0].action;
if (action.command?.id) {
commandService.executeCommand(action.command.id, ...(action.command.arguments || []));
e.preventDefault();
return;
}
focusEditor();
return;
}
// Make sure that focus / cursor location is not lost when clicking widget icon
focusEditor();
this._editor.focus();
e.preventDefault();

// a bit of extra work to make sure the menu
// doesn't cover the line-text
const { top, height } = dom.getDomNodePagePosition(this._domNode);
Expand Down