From ab77235bfb26c3d368c32ba2b22c79eea3e34cca Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Fri, 15 Jun 2018 11:07:39 -0700 Subject: [PATCH] Don't show lightbulb if we only have a selection Removes code action trigger proposal Fixes #52070 --- .../src/features/refactor.ts | 2 +- .../contrib/codeAction/lightBulbWidget.ts | 8 +++++- src/vs/vscode.proposed.d.ts | 27 ------------------- 3 files changed, 8 insertions(+), 29 deletions(-) diff --git a/extensions/typescript-language-features/src/features/refactor.ts b/extensions/typescript-language-features/src/features/refactor.ts index bd65b8481a6..7fc60d4b247 100644 --- a/extensions/typescript-language-features/src/features/refactor.ts +++ b/extensions/typescript-language-features/src/features/refactor.ts @@ -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) { diff --git a/src/vs/editor/contrib/codeAction/lightBulbWidget.ts b/src/vs/editor/contrib/codeAction/lightBulbWidget.ts index 61e18dd6bde..3f7f8538eee 100644 --- a/src/vs/editor/contrib/codeAction/lightBulbWidget.ts +++ b/src/vs/editor/contrib/codeAction/lightBulbWidget.ts @@ -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(); } diff --git a/src/vs/vscode.proposed.d.ts b/src/vs/vscode.proposed.d.ts index 1aa58a1e087..a145720853b 100644 --- a/src/vs/vscode.proposed.d.ts +++ b/src/vs/vscode.proposed.d.ts @@ -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 /** -- GitLab