mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-18 22:29:56 +01:00
Don't show lightbulb if we only have a selection
Removes code action trigger proposal Fixes #52070
This commit is contained in:
@@ -189,7 +189,7 @@ class TypeScriptRefactorProvider implements vscode.CodeActionProvider {
|
||||
return false;
|
||||
}
|
||||
|
||||
return rangeOrSelection instanceof vscode.Selection && (!rangeOrSelection.isEmpty || context.triggerKind === vscode.CodeActionTrigger.Manual);
|
||||
return rangeOrSelection instanceof vscode.Selection;
|
||||
}
|
||||
|
||||
private static getKind(refactor: Proto.RefactorActionInfo) {
|
||||
|
||||
@@ -12,6 +12,7 @@ import 'vs/css!./lightBulbWidget';
|
||||
import { ContentWidgetPositionPreference, ICodeEditor, IContentWidget, IContentWidgetPosition } from 'vs/editor/browser/editorBrowser';
|
||||
import { TextModel } from 'vs/editor/common/model/textModel';
|
||||
import { CodeActionsComputeEvent } from './codeActionModel';
|
||||
import { CodeActionKind } from 'vs/editor/contrib/codeAction/codeActionTrigger';
|
||||
|
||||
export class LightBulbWidget implements IDisposable, IContentWidget {
|
||||
|
||||
@@ -114,9 +115,14 @@ export class LightBulbWidget implements IDisposable, IContentWidget {
|
||||
const { token } = this._futureFixes;
|
||||
this._model = value;
|
||||
|
||||
const selection = this._model.rangeOrSelection;
|
||||
this._model.actions.done(fixes => {
|
||||
if (!token.isCancellationRequested && fixes && fixes.length > 0) {
|
||||
this._show();
|
||||
if (selection.isEmpty() && fixes.every(fix => fix.kind && CodeActionKind.Refactor.contains(fix.kind))) {
|
||||
this.hide();
|
||||
} else {
|
||||
this._show();
|
||||
}
|
||||
} else {
|
||||
this.hide();
|
||||
}
|
||||
|
||||
Vendored
-27
@@ -566,33 +566,6 @@ declare module 'vscode' {
|
||||
}
|
||||
//#endregion
|
||||
|
||||
//#region mjbvz: Code action trigger
|
||||
|
||||
/**
|
||||
* How a [code action provider](#CodeActionProvider) was triggered
|
||||
*/
|
||||
export enum CodeActionTrigger {
|
||||
/**
|
||||
* Provider was triggered automatically by VS Code.
|
||||
*/
|
||||
Automatic = 1,
|
||||
|
||||
/**
|
||||
* User requested code actions.
|
||||
*/
|
||||
Manual = 2,
|
||||
}
|
||||
|
||||
interface CodeActionContext {
|
||||
/**
|
||||
* How the code action provider was triggered.
|
||||
*/
|
||||
triggerKind?: CodeActionTrigger;
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
|
||||
//#region Matt: WebView Serializer
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user