提交 ab77235b 编写于 作者: M Matt Bierner

Don't show lightbulb if we only have a selection

Removes code action trigger proposal

Fixes #52070
上级 74ae993e
......@@ -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();
}
......
......@@ -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
/**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册