Skip to content

Commit

Permalink
Merge pull request #123130 from hediet/hediet/simple-editor-context
Browse files Browse the repository at this point in the history
Introducing SimpleEditorContext for simple widget editors
  • Loading branch information
hediet authored May 6, 2021
2 parents 3d221ca + 40e094c commit 3a04ad7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
17 changes: 17 additions & 0 deletions src/vs/editor/contrib/clipboard/clipboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ export const CutAction = supportsCut ? registerCommand(new MultiCommand({
group: '',
title: nls.localize('actions.clipboard.cutLabel', "Cut"),
order: 1
}, {
menuId: MenuId.SimpleEditorContext,
group: CLIPBOARD_CONTEXT_MENU_GROUP,
title: nls.localize('actions.clipboard.cutLabel', "Cut"),
when: EditorContextKeys.writable,
order: 1,
}]
})) : undefined;

Expand Down Expand Up @@ -91,6 +97,11 @@ export const CopyAction = supportsCopy ? registerCommand(new MultiCommand({
group: '',
title: nls.localize('actions.clipboard.copyLabel', "Copy"),
order: 1
}, {
menuId: MenuId.SimpleEditorContext,
group: CLIPBOARD_CONTEXT_MENU_GROUP,
title: nls.localize('actions.clipboard.copyLabel', "Copy"),
order: 2,
}]
})) : undefined;

Expand Down Expand Up @@ -126,6 +137,12 @@ export const PasteAction = supportsPaste ? registerCommand(new MultiCommand({
group: '',
title: nls.localize('actions.clipboard.pasteLabel', "Paste"),
order: 1
}, {
menuId: MenuId.SimpleEditorContext,
group: CLIPBOARD_CONTEXT_MENU_GROUP,
title: nls.localize('actions.clipboard.pasteLabel', "Paste"),
when: EditorContextKeys.writable,
order: 4,
}]
})) : undefined;

Expand Down
3 changes: 2 additions & 1 deletion src/vs/editor/contrib/contextmenu/contextmenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ export class ContextMenuController implements IEditorContribution {
}

// Find actions available for menu
const menuActions = this._getMenuActions(this._editor.getModel(), MenuId.EditorContext);
const menuActions = this._getMenuActions(this._editor.getModel(),
this._editor.isSimpleWidget ? MenuId.SimpleEditorContext : MenuId.EditorContext);

// Show menu if we have actions to show
if (menuActions.length > 0) {
Expand Down
1 change: 1 addition & 0 deletions src/vs/platform/actions/common/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export class MenuId {
static readonly DebugWatchContext = new MenuId('DebugWatchContext');
static readonly DebugToolBar = new MenuId('DebugToolBar');
static readonly EditorContext = new MenuId('EditorContext');
static readonly SimpleEditorContext = new MenuId('SimpleEditorContext');
static readonly EditorContextCopy = new MenuId('EditorContextCopy');
static readonly EditorContextPeek = new MenuId('EditorContextPeek');
static readonly EditorTitle = new MenuId('EditorTitle');
Expand Down

0 comments on commit 3a04ad7

Please sign in to comment.