Adds menu 'editor/inlineCompletions/actions' that extensions can contribute to.
This commit is contained in:
parent
098dfd56e3
commit
a2d1bd0d15
3 changed files with 32 additions and 7 deletions
|
@ -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<InlineCompletionsHover>,
|
||||
public readonly range: Range
|
||||
|
@ -25,15 +26,15 @@ export class InlineCompletionsHover implements IHoverPart {
|
|||
&& this.range.endColumn >= hoverRange.endColumn
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export class InlineCompletionsHoverParticipant implements IEditorHoverParticipant<InlineCompletionsHover> {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue