diff --git a/src/vs/editor/contrib/inlineCompletions/inlineCompletionsHoverParticipant.ts b/src/vs/editor/contrib/inlineCompletions/inlineCompletionsHoverParticipant.ts index 5781d62dd00..348a5b8d852 100644 --- a/src/vs/editor/contrib/inlineCompletions/inlineCompletionsHoverParticipant.ts +++ b/src/vs/editor/contrib/inlineCompletions/inlineCompletionsHoverParticipant.ts @@ -11,9 +11,10 @@ import { IModelDecoration } from 'vs/editor/common/model'; import { Disposable, IDisposable } from 'vs/base/common/lifecycle'; import { GhostTextController, ShowNextInlineCompletionAction, ShowPreviousInlineCompletionAction } from 'vs/editor/contrib/inlineCompletions/ghostTextController'; import { ICommandService } from 'vs/platform/commands/common/commands'; +import { IMenuService, MenuId, MenuItemAction } from 'vs/platform/actions/common/actions'; +import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; export class InlineCompletionsHover implements IHoverPart { - constructor( public readonly owner: IEditorHoverParticipant, public readonly range: Range @@ -25,15 +26,15 @@ export class InlineCompletionsHover implements IHoverPart { && this.range.endColumn >= hoverRange.endColumn ); } - } export class InlineCompletionsHoverParticipant implements IEditorHoverParticipant { - constructor( private readonly _editor: ICodeEditor, hover: IEditorHover, @ICommandService private readonly _commandService: ICommandService, + @IMenuService private readonly _menuService: IMenuService, + @IContextKeyService private readonly _contextKeyService: IContextKeyService, ) { } computeSync(hoverRange: Range, lineDecorations: IModelDecoration[]): InlineCompletionsHover[] { @@ -45,17 +46,34 @@ export class InlineCompletionsHoverParticipant implements IEditorHoverParticipan } renderHoverParts(hoverParts: InlineCompletionsHover[], fragment: DocumentFragment, statusBar: EditorHoverStatusBar): IDisposable { + const menu = this._menuService.createMenu( + MenuId.InlineCompletionsActions, + this._contextKeyService + ); + statusBar.addAction({ - label: nls.localize('showPreviousInlineCompletion', "⬅️ Previous"), + label: nls.localize('showPreviousInlineCompletion', "Previous"), commandId: ShowPreviousInlineCompletionAction.ID, run: () => this._commandService.executeCommand(ShowPreviousInlineCompletionAction.ID) }); statusBar.addAction({ - label: nls.localize('showNextInlineCompletion', "Next ➡️"), + label: nls.localize('showNextInlineCompletion', "Next"), commandId: ShowNextInlineCompletionAction.ID, run: () => this._commandService.executeCommand(ShowNextInlineCompletionAction.ID) }); + + for (const [_, group] of menu.getActions()) { + for (const action of group) { + if (action instanceof MenuItemAction) { + statusBar.addAction({ + label: action.label, + commandId: action.item.id, + run: () => this._commandService.executeCommand(action.item.id) + }); + } + } + } + return Disposable.None; } - } diff --git a/src/vs/platform/actions/common/actions.ts b/src/vs/platform/actions/common/actions.ts index 27f03169442..f0e548fea19 100644 --- a/src/vs/platform/actions/common/actions.ts +++ b/src/vs/platform/actions/common/actions.ts @@ -171,6 +171,7 @@ export class MenuId { static readonly TerminalTabEmptyAreaContext = new MenuId('TerminalTabEmptyAreaContext'); static readonly TerminalInlineTabContext = new MenuId('TerminalInlineTabContext'); static readonly WebviewContext = new MenuId('WebviewContext'); + static readonly InlineCompletionsActions = new MenuId('InlineCompletionsActions'); readonly id: number; readonly _debugName: string; diff --git a/src/vs/workbench/api/common/menusExtensionPoint.ts b/src/vs/workbench/api/common/menusExtensionPoint.ts index 71aa38a9fee..b7e24d0765e 100644 --- a/src/vs/workbench/api/common/menusExtensionPoint.ts +++ b/src/vs/workbench/api/common/menusExtensionPoint.ts @@ -229,7 +229,13 @@ const apiMenus: IAPIMenu[] = [ key: 'ports/item/port/inline', id: MenuId.TunnelPortInline, description: localize('view.tunnelPortInline', "The Ports view item port inline menu") - } + }, + { + key: 'editor/inlineCompletions/actions', + id: MenuId.InlineCompletionsActions, + description: localize('inlineCompletions.actions', "The actions shown when hovering on an inline completion"), + supportsSubmenus: false + }, ]; namespace schema {