Skip to content

Commit ec12178

Browse files
authored
Always use custom code action widget (microsoft#159614)
Also updates setting names to use `widget` instead of `menu`
1 parent c96574c commit ec12178

File tree

2 files changed

+10
-60
lines changed

2 files changed

+10
-60
lines changed

src/vs/editor/contrib/codeAction/browser/codeActionMenu.ts

Lines changed: 8 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,35 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import * as dom from 'vs/base/browser/dom';
7+
import { ActionBar } from 'vs/base/browser/ui/actionbar/actionbar';
8+
import 'vs/base/browser/ui/codicons/codiconStyles'; // The codicon symbol styles are defined here and must be loaded
79
import { IAnchor } from 'vs/base/browser/ui/contextview/contextview';
810
import { IListEvent, IListMouseEvent, IListRenderer } from 'vs/base/browser/ui/list/list';
911
import { List } from 'vs/base/browser/ui/list/listWidget';
1012
import { Action, IAction, Separator } from 'vs/base/common/actions';
13+
import { Codicon } from 'vs/base/common/codicons';
1114
import { canceled } from 'vs/base/common/errors';
1215
import { ResolvedKeybinding } from 'vs/base/common/keybindings';
1316
import { Lazy } from 'vs/base/common/lazy';
14-
import { Disposable, MutableDisposable, IDisposable, DisposableStore } from 'vs/base/common/lifecycle';
17+
import { Disposable, DisposableStore, IDisposable, MutableDisposable } from 'vs/base/common/lifecycle';
1518
import 'vs/css!./media/action';
1619
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
17-
import { EditorOption } from 'vs/editor/common/config/editorOptions';
1820
import { IPosition, Position } from 'vs/editor/common/core/position';
1921
import { IEditorContribution, ScrollType } from 'vs/editor/common/editorCommon';
2022
import { CodeAction, Command } from 'vs/editor/common/languages';
2123
import { ITextModel } from 'vs/editor/common/model';
2224
import { ILanguageFeaturesService } from 'vs/editor/common/services/languageFeatures';
2325
import { codeActionCommandId, CodeActionItem, CodeActionSet, fixAllCommandId, organizeImportsCommandId, refactorCommandId, sourceActionCommandId } from 'vs/editor/contrib/codeAction/browser/codeAction';
2426
import { CodeActionAutoApply, CodeActionCommandArgs, CodeActionKind, CodeActionTrigger, CodeActionTriggerSource } from 'vs/editor/contrib/codeAction/browser/types';
27+
import 'vs/editor/contrib/symbolIcons/browser/symbolIcons'; // The codicon symbol colors are defined here and must be loaded to get colors
2528
import { localize } from 'vs/nls';
2629
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
2730
import { IContextKey, IContextKeyService, RawContextKey } from 'vs/platform/contextkey/common/contextkey';
28-
import { IContextMenuService, IContextViewService } from 'vs/platform/contextview/browser/contextView';
31+
import { IContextViewService } from 'vs/platform/contextview/browser/contextView';
2932
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
3033
import { ResolvedKeybindingItem } from 'vs/platform/keybinding/common/resolvedKeybindingItem';
3134
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
3235
import { IThemeService } from 'vs/platform/theme/common/themeService';
33-
import 'vs/base/browser/ui/codicons/codiconStyles'; // The codicon symbol styles are defined here and must be loaded
34-
import 'vs/editor/contrib/symbolIcons/browser/symbolIcons'; // The codicon symbol colors are defined here and must be loaded to get colors
35-
import { Codicon } from 'vs/base/common/codicons';
36-
import { ActionBar } from 'vs/base/browser/ui/actionbar/actionbar';
3736

3837
export const Context = {
3938
Visible: new RawContextKey<boolean>('codeActionMenuVisible', false, localize('codeActionMenuVisible', "Whether the code action list widget is visible"))
@@ -309,12 +308,9 @@ export class CodeActionMenu extends Disposable implements IEditorContribution {
309308
return editor.getContribution<CodeActionMenu>(CodeActionMenu.ID);
310309
}
311310

312-
private readonly _keybindingResolver: CodeActionKeybindingResolver;
313-
314311
constructor(
315312
private readonly _editor: ICodeEditor,
316313
private readonly _delegate: CodeActionWidgetDelegate,
317-
@IContextMenuService private readonly _contextMenuService: IContextMenuService,
318314
@IKeybindingService private readonly keybindingService: IKeybindingService,
319315
@ILanguageFeaturesService private readonly _languageFeaturesService: ILanguageFeaturesService,
320316
@ITelemetryService private readonly _telemetryService: ITelemetryService,
@@ -325,31 +321,18 @@ export class CodeActionMenu extends Disposable implements IEditorContribution {
325321
) {
326322
super();
327323

328-
this._keybindingResolver = new CodeActionKeybindingResolver({
329-
getKeybindings: () => keybindingService.getKeybindings()
330-
});
331-
332324
this._ctxMenuWidgetVisible = Context.Visible.bindTo(this._contextKeyService);
333325
}
334326

335327
get isVisible(): boolean {
336328
return this._visible;
337329
}
338330

339-
/**
340-
* Checks if the settings have enabled the new code action widget.
341-
*/
342-
private isCodeActionWidgetEnabled(model: ITextModel): boolean {
343-
return this._configurationService.getValue('editor.useCustomCodeActionMenu', {
344-
resource: model.uri
345-
});
346-
}
347-
348331
/**
349332
* Checks if the setting has disabled/enabled headers in the code action widget.
350333
*/
351334
private isCodeActionWidgetHeadersShown(model: ITextModel): boolean {
352-
return this._configurationService.getValue('editor.customCodeActionMenu.showHeaders', {
335+
return this._configurationService.getValue('editor.codeActionWidget.showHeaders', {
353336
resource: model.uri
354337
});
355338
}
@@ -810,28 +793,7 @@ export class CodeActionMenu extends Disposable implements IEditorContribution {
810793
const anchor = Position.isIPosition(at) ? this._toCoords(at) : at || { x: 0, y: 0 };
811794

812795
const params = <ICodeActionMenuParameters>{ options, trigger, codeActions, anchor, menuActions, showDisabled: true, visible: this._visible, menuObj: this };
813-
const resolver = this._keybindingResolver.getResolver();
814-
815-
const useShadowDOM = this._editor.getOption(EditorOption.useShadowDOM);
816-
817-
818-
if (this.isCodeActionWidgetEnabled(model)) {
819-
this.showContextViewHelper(params, menuActions);
820-
} else {
821-
this._contextMenuService.showContextMenu({
822-
domForShadowRoot: useShadowDOM ? this._editor.getDomNode()! : undefined,
823-
getAnchor: () => anchor,
824-
getActions: () => menuActions,
825-
onHide: (didCancel) => {
826-
const openedFromString = (options.fromLightbulb) ? CodeActionTriggerSource.Lightbulb : trigger.triggerAction;
827-
this.codeActionTelemetry(openedFromString, didCancel, codeActions);
828-
this._visible = false;
829-
this._editor.focus();
830-
},
831-
autoSelectFirstItem: true,
832-
getKeyBinding: action => action instanceof CodeActionAction ? resolver(action.action) : undefined,
833-
});
834-
}
796+
this.showContextViewHelper(params, menuActions);
835797
}
836798

837799
private getMenuActions(

src/vs/editor/contrib/codeAction/browser/codeActionWidgetContribution.ts

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,10 @@ import { Registry } from 'vs/platform/registry/common/platform';
1111
Registry.as<IConfigurationRegistry>(Extensions.Configuration).registerConfiguration({
1212
...editorConfigurationBaseNode,
1313
properties: {
14-
'editor.useCustomCodeActionMenu': {
14+
'editor.codeActionWidget.showHeaders': {
1515
type: 'boolean',
1616
scope: ConfigurationScope.LANGUAGE_OVERRIDABLE,
17-
description: nls.localize('codeActionWidget', "Enabling this adjusts how the code action menu is rendered."),
18-
default: true,
19-
},
20-
}
21-
});
22-
23-
Registry.as<IConfigurationRegistry>(Extensions.Configuration).registerConfiguration({
24-
...editorConfigurationBaseNode,
25-
properties: {
26-
'editor.customCodeActionMenu.showHeaders': {
27-
type: 'boolean',
28-
scope: ConfigurationScope.LANGUAGE_OVERRIDABLE,
29-
description: nls.localize('showCodeActionHeaders', "Enabling this will show the code action menu with group headers, if the custom code action menu is enabled."),
17+
description: nls.localize('showCodeActionHeaders', "Enable/disable showing group headers in the code action menu."),
3018
default: true,
3119
},
3220
}

0 commit comments

Comments
 (0)