Skip to content

Commit

Permalink
Fix 'quick fixes'
Browse files Browse the repository at this point in the history
Signed-off-by: Roman Nikitenko <[email protected]>
  • Loading branch information
RomanNikitenko committed Mar 17, 2020
1 parent c40f846 commit c1a8936
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
6 changes: 2 additions & 4 deletions packages/monaco/src/browser/monaco-context-menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,10 @@ export class MonacoContextMenuService implements IContextMenuService {

showContextMenu(delegate: IContextMenuDelegate): void {
const anchor = toAnchor(delegate.getAnchor());
// If it is the general context menu, we want to delegate to our menu registry entirely and ignore the actually passed actions.
// Unfortunately checking the existence of certain properties seems to be the best way to tell, what kind of context menu is requested.
if (delegate.hasOwnProperty('getKeyBinding')) {
const actions = delegate.getActions();
if (actions.length > 0 && actions[0] instanceof monaco.actions.MenuItemAction) {
this.contextMenuRenderer.render(EDITOR_CONTEXT_MENU, anchor, () => delegate.onHide(false));
} else {
const actions = delegate.getActions();
const commands = new CommandRegistry();
const menu = new Menu({
commands
Expand Down
19 changes: 19 additions & 0 deletions packages/monaco/src/typings/monaco/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,25 @@ declare module monaco.actions {
*/
// https://github.com/theia-ide/vscode/blob/standalone/0.19.x/src/vs/platform/actions/common/actions.ts#L142
export const MenuRegistry: IMenuRegistry;

// https://github.com/theia-ide/vscode/blob/standalone/0.19.x/src/vs/platform/actions/common/actions.ts#L112
export interface IMenuActionOptions {
arg?: any;
shouldForwardArgs?: boolean;
}

// https://github.com/theia-ide/vscode/blob/standalone/0.19.x/src/vs/platform/actions/common/actions.ts#L246
export class MenuItemAction {
readonly item: ICommandAction;
readonly alt: MenuItemAction | undefined;
constructor(
item: ICommandAction,
alt: ICommandAction | undefined,
options: IMenuActionOptions,
contextKeyService: monaco.contextKeyService.IContextKeyService,
commandService: monaco.commands.ICommandService
)
}
}

declare module monaco.platform {
Expand Down

0 comments on commit c1a8936

Please sign in to comment.