diff options
author | Justin Chen <t-justinchen@microsoft.com> | 2022-07-27 01:27:52 +0300 |
---|---|---|
committer | Justin Chen <t-justinchen@microsoft.com> | 2022-07-27 01:27:52 +0300 |
commit | d31f53b5dc057aff1fe9513f62d283bd608e6100 (patch) | |
tree | cd66442a23469af9800dc0a973bf56557b649181 /src/vs | |
parent | 3cc267b93b47f19e885afbd2f2c4f2a2941c974b (diff) |
code clean up and fix on documentation type check
Diffstat (limited to 'src/vs')
-rw-r--r-- | src/vs/editor/contrib/codeAction/browser/codeActionCommands.ts | 5 | ||||
-rw-r--r-- | src/vs/editor/contrib/codeAction/browser/codeActionMenu.ts | 18 |
2 files changed, 13 insertions, 10 deletions
diff --git a/src/vs/editor/contrib/codeAction/browser/codeActionCommands.ts b/src/vs/editor/contrib/codeAction/browser/codeActionCommands.ts index 6c6f5fb306f..7f106ceba40 100644 --- a/src/vs/editor/contrib/codeAction/browser/codeActionCommands.ts +++ b/src/vs/editor/contrib/codeAction/browser/codeActionCommands.ts @@ -152,7 +152,10 @@ export class QuickFixController extends Disposable implements IEditorContributio } public selectedOptionWithPreview() { - this._ui.getValue().onPreviewEnter(); + if (this._ui.hasValue()) { + this._ui.getValue().onPreviewEnter(); + } + } public showCodeActions(trigger: CodeActionTrigger, actions: CodeActionSet, at: IAnchor | IPosition) { diff --git a/src/vs/editor/contrib/codeAction/browser/codeActionMenu.ts b/src/vs/editor/contrib/codeAction/browser/codeActionMenu.ts index 0cc02fbc935..8ce748081a0 100644 --- a/src/vs/editor/contrib/codeAction/browser/codeActionMenu.ts +++ b/src/vs/editor/contrib/codeAction/browser/codeActionMenu.ts @@ -96,10 +96,9 @@ const codeActionLineHeight = 26; class CodeMenuRenderer implements IListRenderer<ICodeActionMenuItem, ICodeActionMenuTemplateData> { constructor( + private readonly acceptKeybindings: [string, string], @IKeybindingService private readonly keybindingService: IKeybindingService, - ) { - - } + ) { } get templateId(): string { return TEMPLATE_ID; } @@ -141,8 +140,9 @@ class CodeMenuRenderer implements IListRenderer<ICodeActionMenuItem, ICodeAction if (!isDocumentation) { const updateLabel = () => { - const [accept, preview] = [`onEnterSelectCodeAction`, `onEnterSelectCodeActionWithPreview`]; - data.root.title = this.keybindingService.lookupKeybinding(accept)?.getLabel() + ' to Refactor, ' + this.keybindingService.lookupKeybinding(preview)?.getLabel() + ' to Preview'; + const [accept, preview] = this.acceptKeybindings; + data.root.title = localize({ key: 'label', comment: ['placeholders are keybindings, e.g "F2 to Refactor, Shift+F2 to Preview"'] }, "{0} to Rename, {1} to Preview", this.keybindingService.lookupKeybinding(accept)?.getLabel(), this.keybindingService.lookupKeybinding(preview)?.getLabel()); + // data.root.title = this.keybindingService.lookupKeybinding(accept)?.getLabel() + ' to Refactor, ' + this.keybindingService.lookupKeybinding(preview)?.getLabel() + ' to Preview'; }; updateLabel(); } @@ -193,7 +193,7 @@ export class CodeActionMenu extends Disposable implements IEditorContribution { }); this._ctxMenuWidgetVisible = Context.Visible.bindTo(this._contextKeyService); - this.listRenderer = new CodeMenuRenderer(keybindingService); + this.listRenderer = new CodeMenuRenderer([`onEnterSelectCodeAction`, `onEnterSelectCodeActionWithPreview`], keybindingService); } get isVisible(): boolean { @@ -315,7 +315,7 @@ export class CodeActionMenu extends Disposable implements IEditorContribution { this.codeActionList.value?.layout(height, maxWidth); // List selection - if (this.viewItems.length < 1 || (this.viewItems.length === 1 && this.viewItems[0].isDocumentation)) { + if (this.viewItems.length < 1 || this.viewItems.every(item => item.isDocumentation)) { this.currSelectedItem = 0; } else { this.focusedEnabledItem = 0; @@ -340,7 +340,7 @@ export class CodeActionMenu extends Disposable implements IEditorContribution { protected focusPrevious() { if (typeof this.focusedEnabledItem === 'undefined') { this.focusedEnabledItem = this.viewItems[0].index; - } else if (this.viewItems.length < 1 || (this.viewItems.length === 1 && !this.viewItems[0].isDocumentation)) { + } else if (this.viewItems.length < 1) { return false; } @@ -363,7 +363,7 @@ export class CodeActionMenu extends Disposable implements IEditorContribution { protected focusNext() { if (typeof this.focusedEnabledItem === 'undefined') { this.focusedEnabledItem = this.viewItems.length - 1; - } else if (this.viewItems.length < 1 || (this.viewItems.length === 1 && !this.viewItems[0].isDocumentation)) { + } else if (this.viewItems.length < 1) { return false; } |