Skip to content

Commit ab77235

Browse files
committed
Don't show lightbulb if we only have a selection
Removes code action trigger proposal Fixes microsoft#52070
1 parent 74ae993 commit ab77235

3 files changed

Lines changed: 8 additions & 29 deletions

File tree

extensions/typescript-language-features/src/features/refactor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ class TypeScriptRefactorProvider implements vscode.CodeActionProvider {
189189
return false;
190190
}
191191

192-
return rangeOrSelection instanceof vscode.Selection && (!rangeOrSelection.isEmpty || context.triggerKind === vscode.CodeActionTrigger.Manual);
192+
return rangeOrSelection instanceof vscode.Selection;
193193
}
194194

195195
private static getKind(refactor: Proto.RefactorActionInfo) {

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import 'vs/css!./lightBulbWidget';
1212
import { ContentWidgetPositionPreference, ICodeEditor, IContentWidget, IContentWidgetPosition } from 'vs/editor/browser/editorBrowser';
1313
import { TextModel } from 'vs/editor/common/model/textModel';
1414
import { CodeActionsComputeEvent } from './codeActionModel';
15+
import { CodeActionKind } from 'vs/editor/contrib/codeAction/codeActionTrigger';
1516

1617
export class LightBulbWidget implements IDisposable, IContentWidget {
1718

@@ -114,9 +115,14 @@ export class LightBulbWidget implements IDisposable, IContentWidget {
114115
const { token } = this._futureFixes;
115116
this._model = value;
116117

118+
const selection = this._model.rangeOrSelection;
117119
this._model.actions.done(fixes => {
118120
if (!token.isCancellationRequested && fixes && fixes.length > 0) {
119-
this._show();
121+
if (selection.isEmpty() && fixes.every(fix => fix.kind && CodeActionKind.Refactor.contains(fix.kind))) {
122+
this.hide();
123+
} else {
124+
this._show();
125+
}
120126
} else {
121127
this.hide();
122128
}

src/vs/vscode.proposed.d.ts

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -566,33 +566,6 @@ declare module 'vscode' {
566566
}
567567
//#endregion
568568

569-
//#region mjbvz: Code action trigger
570-
571-
/**
572-
* How a [code action provider](#CodeActionProvider) was triggered
573-
*/
574-
export enum CodeActionTrigger {
575-
/**
576-
* Provider was triggered automatically by VS Code.
577-
*/
578-
Automatic = 1,
579-
580-
/**
581-
* User requested code actions.
582-
*/
583-
Manual = 2,
584-
}
585-
586-
interface CodeActionContext {
587-
/**
588-
* How the code action provider was triggered.
589-
*/
590-
triggerKind?: CodeActionTrigger;
591-
}
592-
593-
//#endregion
594-
595-
596569
//#region Matt: WebView Serializer
597570

598571
/**

0 commit comments

Comments
 (0)