Move Edit menu registrations next to the actions (#54510)

This commit is contained in:
Alex Dima 2018-07-24 18:30:28 +02:00
parent d58a9f36f3
commit f5494e1f74
8 changed files with 89 additions and 122 deletions

View file

@ -5,6 +5,7 @@
'use strict'; 'use strict';
import * as nls from 'vs/nls';
import { Position } from 'vs/editor/common/core/position'; import { Position } from 'vs/editor/common/core/position';
import { Range } from 'vs/editor/common/core/range'; import { Range } from 'vs/editor/common/core/range';
import * as editorCommon from 'vs/editor/common/editorCommon'; import * as editorCommon from 'vs/editor/common/editorCommon';
@ -26,6 +27,7 @@ import { TypeOperations } from 'vs/editor/common/controller/cursorTypeOperations
import { DeleteOperations } from 'vs/editor/common/controller/cursorDeleteOperations'; import { DeleteOperations } from 'vs/editor/common/controller/cursorDeleteOperations';
import { VerticalRevealType } from 'vs/editor/common/view/viewEvents'; import { VerticalRevealType } from 'vs/editor/common/view/viewEvents';
import { ICodeEditor } from 'vs/editor/browser/editorBrowser'; import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
import { MenuId } from 'vs/platform/actions/common/actions';
const CORE_WEIGHT = KeybindingWeight.EditorCore; const CORE_WEIGHT = KeybindingWeight.EditorCore;
@ -1721,6 +1723,12 @@ registerCommand(new EditorOrNativeTextInputCommand({
weight: CORE_WEIGHT, weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.textInputFocus, kbExpr: EditorContextKeys.textInputFocus,
primary: KeyMod.CtrlCmd | KeyCode.KEY_Z primary: KeyMod.CtrlCmd | KeyCode.KEY_Z
},
menubarOpts: {
menuId: MenuId.MenubarEditMenu,
group: '1_do',
title: nls.localize({ key: 'miUndo', comment: ['&& denotes a mnemonic'] }, "&&Undo"),
order: 1
} }
})); }));
registerCommand(new EditorHandlerCommand('default:' + H.Undo, H.Undo)); registerCommand(new EditorHandlerCommand('default:' + H.Undo, H.Undo));
@ -1736,6 +1744,12 @@ registerCommand(new EditorOrNativeTextInputCommand({
primary: KeyMod.CtrlCmd | KeyCode.KEY_Y, primary: KeyMod.CtrlCmd | KeyCode.KEY_Y,
secondary: [KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_Z], secondary: [KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_Z],
mac: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_Z } mac: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_Z }
},
menubarOpts: {
menuId: MenuId.MenubarEditMenu,
group: '1_do',
title: nls.localize({ key: 'miRedo', comment: ['&& denotes a mnemonic'] }, "&&Redo"),
order: 2
} }
})); }));
registerCommand(new EditorHandlerCommand('default:' + H.Redo, H.Redo)); registerCommand(new EditorHandlerCommand('default:' + H.Redo, H.Redo));

View file

@ -17,6 +17,7 @@ import { CopyOptions } from 'vs/editor/browser/controller/textAreaInput';
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys'; import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
import { ICodeEditor } from 'vs/editor/browser/editorBrowser'; import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
import { MenuId } from 'vs/platform/actions/common/actions';
const CLIPBOARD_CONTEXT_MENU_GROUP = '9_cutcopypaste'; const CLIPBOARD_CONTEXT_MENU_GROUP = '9_cutcopypaste';
@ -80,6 +81,12 @@ class ExecCommandCutAction extends ExecCommandAction {
menuOpts: { menuOpts: {
group: CLIPBOARD_CONTEXT_MENU_GROUP, group: CLIPBOARD_CONTEXT_MENU_GROUP,
order: 1 order: 1
},
menubarOpts: {
menuId: MenuId.MenubarEditMenu,
group: '2_ccp',
title: nls.localize({ key: 'miCut', comment: ['&& denotes a mnemonic'] }, "Cu&&t"),
order: 1
} }
}); });
} }
@ -119,6 +126,12 @@ class ExecCommandCopyAction extends ExecCommandAction {
menuOpts: { menuOpts: {
group: CLIPBOARD_CONTEXT_MENU_GROUP, group: CLIPBOARD_CONTEXT_MENU_GROUP,
order: 2 order: 2
},
menubarOpts: {
menuId: MenuId.MenubarEditMenu,
group: '2_ccp',
title: nls.localize({ key: 'miCopy', comment: ['&& denotes a mnemonic'] }, "&&Copy"),
order: 2
} }
}); });
} }
@ -158,6 +171,12 @@ class ExecCommandPasteAction extends ExecCommandAction {
menuOpts: { menuOpts: {
group: CLIPBOARD_CONTEXT_MENU_GROUP, group: CLIPBOARD_CONTEXT_MENU_GROUP,
order: 3 order: 3
},
menubarOpts: {
menuId: MenuId.MenubarEditMenu,
group: '2_ccp',
title: nls.localize({ key: 'miPaste', comment: ['&& denotes a mnemonic'] }, "&&Paste"),
order: 3
} }
}); });
} }

View file

@ -13,6 +13,7 @@ import { BlockCommentCommand } from './blockCommentCommand';
import { LineCommentCommand, Type } from './lineCommentCommand'; import { LineCommentCommand, Type } from './lineCommentCommand';
import { ICodeEditor } from 'vs/editor/browser/editorBrowser'; import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
import { MenuId } from 'vs/platform/actions/common/actions';
abstract class CommentLineAction extends EditorAction { abstract class CommentLineAction extends EditorAction {
@ -55,6 +56,12 @@ class ToggleCommentLineAction extends CommentLineAction {
kbExpr: EditorContextKeys.editorTextFocus, kbExpr: EditorContextKeys.editorTextFocus,
primary: KeyMod.CtrlCmd | KeyCode.US_SLASH, primary: KeyMod.CtrlCmd | KeyCode.US_SLASH,
weight: KeybindingWeight.EditorContrib weight: KeybindingWeight.EditorContrib
},
menubarOpts: {
menuId: MenuId.MenubarEditMenu,
group: '5_insert',
title: nls.localize({ key: 'miToggleLineComment', comment: ['&& denotes a mnemonic'] }, "&&Toggle Line Comment"),
order: 1
} }
}); });
} }
@ -105,6 +112,12 @@ class BlockCommentAction extends EditorAction {
primary: KeyMod.Shift | KeyMod.Alt | KeyCode.KEY_A, primary: KeyMod.Shift | KeyMod.Alt | KeyCode.KEY_A,
linux: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_A }, linux: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_A },
weight: KeybindingWeight.EditorContrib weight: KeybindingWeight.EditorContrib
},
menubarOpts: {
menuId: MenuId.MenubarEditMenu,
group: '5_insert',
title: nls.localize({ key: 'miToggleBlockComment', comment: ['&& denotes a mnemonic'] }, "Toggle &&Block Comment"),
order: 2
} }
}); });
} }

View file

@ -25,6 +25,7 @@ import { FindOptionsWidget } from 'vs/editor/contrib/find/findOptionsWidget';
import { IThemeService } from 'vs/platform/theme/common/themeService'; import { IThemeService } from 'vs/platform/theme/common/themeService';
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
import { optional } from 'vs/platform/instantiation/common/instantiation'; import { optional } from 'vs/platform/instantiation/common/instantiation';
import { MenuId } from 'vs/platform/actions/common/actions';
export function getSelectionSearchString(editor: ICodeEditor): string { export function getSelectionSearchString(editor: ICodeEditor): string {
let selection = editor.getSelection(); let selection = editor.getSelection();
@ -388,6 +389,12 @@ export class StartFindAction extends EditorAction {
kbExpr: null, kbExpr: null,
primary: KeyMod.CtrlCmd | KeyCode.KEY_F, primary: KeyMod.CtrlCmd | KeyCode.KEY_F,
weight: KeybindingWeight.EditorContrib weight: KeybindingWeight.EditorContrib
},
menubarOpts: {
menuId: MenuId.MenubarEditMenu,
group: '3_find',
title: nls.localize({ key: 'miFind', comment: ['&& denotes a mnemonic'] }, "&&Find"),
order: 1
} }
}); });
} }
@ -582,6 +589,12 @@ export class StartFindReplaceAction extends EditorAction {
primary: KeyMod.CtrlCmd | KeyCode.KEY_H, primary: KeyMod.CtrlCmd | KeyCode.KEY_H,
mac: { primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.KEY_F }, mac: { primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.KEY_F },
weight: KeybindingWeight.EditorContrib weight: KeybindingWeight.EditorContrib
},
menubarOpts: {
menuId: MenuId.MenubarEditMenu,
group: '3_find',
title: nls.localize({ key: 'miReplace', comment: ['&& denotes a mnemonic'] }, "&&Replace"),
order: 2
} }
}); });
} }

View file

@ -7,130 +7,8 @@
import * as nls from 'vs/nls'; import * as nls from 'vs/nls';
import { MenuRegistry, MenuId } from 'vs/platform/actions/common/actions'; import { MenuRegistry, MenuId } from 'vs/platform/actions/common/actions';
editMenuRegistration();
selectionMenuRegistration(); selectionMenuRegistration();
function editMenuRegistration() {
MenuRegistry.appendMenuItem(MenuId.MenubarEditMenu, {
group: '1_do',
command: {
id: 'undo',
title: nls.localize({ key: 'miUndo', comment: ['&& denotes a mnemonic'] }, "&&Undo")
},
order: 1
});
MenuRegistry.appendMenuItem(MenuId.MenubarEditMenu, {
group: '1_do',
command: {
id: 'redo',
title: nls.localize({ key: 'miRedo', comment: ['&& denotes a mnemonic'] }, "&&Redo")
},
order: 2
});
MenuRegistry.appendMenuItem(MenuId.MenubarEditMenu, {
group: '2_ccp',
command: {
id: 'editor.action.clipboardCutAction',
title: nls.localize({ key: 'miCut', comment: ['&& denotes a mnemonic'] }, "Cu&&t")
},
order: 1
});
MenuRegistry.appendMenuItem(MenuId.MenubarEditMenu, {
group: '2_ccp',
command: {
id: 'editor.action.clipboardCopyAction',
title: nls.localize({ key: 'miCopy', comment: ['&& denotes a mnemonic'] }, "&&Copy")
},
order: 2
});
MenuRegistry.appendMenuItem(MenuId.MenubarEditMenu, {
group: '2_ccp',
command: {
id: 'editor.action.clipboardPasteAction',
title: nls.localize({ key: 'miPaste', comment: ['&& denotes a mnemonic'] }, "&&Paste")
},
order: 3
});
MenuRegistry.appendMenuItem(MenuId.MenubarEditMenu, {
group: '3_find',
command: {
id: 'actions.find',
title: nls.localize({ key: 'miFind', comment: ['&& denotes a mnemonic'] }, "&&Find")
},
order: 1
});
MenuRegistry.appendMenuItem(MenuId.MenubarEditMenu, {
group: '3_find',
command: {
id: 'editor.action.startFindReplaceAction',
title: nls.localize({ key: 'miReplace', comment: ['&& denotes a mnemonic'] }, "&&Replace")
},
order: 2
});
MenuRegistry.appendMenuItem(MenuId.MenubarEditMenu, {
group: '4_find_global',
command: {
id: 'workbench.action.findInFiles',
title: nls.localize({ key: 'miFindInFiles', comment: ['&& denotes a mnemonic'] }, "Find &&in Files")
},
order: 1
});
MenuRegistry.appendMenuItem(MenuId.MenubarEditMenu, {
group: '4_find_global',
command: {
id: 'workbench.action.replaceInFiles',
title: nls.localize({ key: 'miReplaceInFiles', comment: ['&& denotes a mnemonic'] }, "Replace &&in Files")
},
order: 2
});
MenuRegistry.appendMenuItem(MenuId.MenubarEditMenu, {
group: '5_insert',
command: {
id: 'editor.action.commentLine',
title: nls.localize({ key: 'miToggleLineComment', comment: ['&& denotes a mnemonic'] }, "&&Toggle Line Comment")
},
order: 1
});
MenuRegistry.appendMenuItem(MenuId.MenubarEditMenu, {
group: '5_insert',
command: {
id: 'editor.action.blockComment',
title: nls.localize({ key: 'miToggleBlockComment', comment: ['&& denotes a mnemonic'] }, "Toggle &&Block Comment")
},
order: 2
});
MenuRegistry.appendMenuItem(MenuId.MenubarEditMenu, {
group: '5_insert',
command: {
id: 'editor.emmet.action.expandAbbreviation',
title: nls.localize({ key: 'miEmmetExpandAbbreviation', comment: ['&& denotes a mnemonic'] }, "Emmet: E&&xpand Abbreviation")
},
order: 1
});
MenuRegistry.appendMenuItem(MenuId.MenubarEditMenu, {
group: '5_insert',
command: {
id: 'workbench.action.showEmmetCommands',
title: nls.localize({ key: 'miShowEmmetCommands', comment: ['&& denotes a mnemonic'] }, "E&&mmet...")
},
order: 2
});
}
function selectionMenuRegistration() { function selectionMenuRegistration() {
MenuRegistry.appendMenuItem(MenuId.MenubarSelectionMenu, { MenuRegistry.appendMenuItem(MenuId.MenubarSelectionMenu, {
group: '1_basic', group: '1_basic',

View file

@ -12,6 +12,7 @@ import { registerEditorAction, EditorAction, ServicesAccessor } from 'vs/editor/
import { IQuickOpenService } from 'vs/platform/quickOpen/common/quickOpen'; import { IQuickOpenService } from 'vs/platform/quickOpen/common/quickOpen';
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys'; import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
import { ICodeEditor } from 'vs/editor/browser/editorBrowser'; import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
import { MenuId } from 'vs/platform/actions/common/actions';
const EMMET_COMMANDS_PREFIX = '>Emmet: '; const EMMET_COMMANDS_PREFIX = '>Emmet: ';
@ -23,6 +24,12 @@ class ShowEmmetCommandsAction extends EditorAction {
label: nls.localize('showEmmetCommands', "Show Emmet Commands"), label: nls.localize('showEmmetCommands', "Show Emmet Commands"),
alias: 'Show Emmet Commands', alias: 'Show Emmet Commands',
precondition: EditorContextKeys.writable, precondition: EditorContextKeys.writable,
menubarOpts: {
menuId: MenuId.MenubarEditMenu,
group: '5_insert',
title: nls.localize({ key: 'miShowEmmetCommands', comment: ['&& denotes a mnemonic'] }, "E&&mmet..."),
order: 4
}
}); });
} }

View file

@ -11,6 +11,7 @@ import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
import { KeyCode } from 'vs/base/common/keyCodes'; import { KeyCode } from 'vs/base/common/keyCodes';
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey'; import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
import { MenuId } from 'vs/platform/actions/common/actions';
class ExpandAbbreviationAction extends EmmetEditorAction { class ExpandAbbreviationAction extends EmmetEditorAction {
@ -29,6 +30,12 @@ class ExpandAbbreviationAction extends EmmetEditorAction {
ContextKeyExpr.has('config.emmet.triggerExpansionOnTab') ContextKeyExpr.has('config.emmet.triggerExpansionOnTab')
), ),
weight: KeybindingWeight.EditorContrib weight: KeybindingWeight.EditorContrib
},
menubarOpts: {
menuId: MenuId.MenubarEditMenu,
group: '5_insert',
title: nls.localize({ key: 'miEmmetExpandAbbreviation', comment: ['&& denotes a mnemonic'] }, "Emmet: E&&xpand Abbreviation"),
order: 3
} }
}); });

View file

@ -476,11 +476,27 @@ const registry = Registry.as<IWorkbenchActionRegistry>(ActionExtensions.Workbenc
// Show Search 'when' is redundant but if the two conflict with exactly the same keybinding and 'when' clause, then they can show up as "unbound" - #51780 // Show Search 'when' is redundant but if the two conflict with exactly the same keybinding and 'when' clause, then they can show up as "unbound" - #51780
registry.registerWorkbenchAction(new SyncActionDescriptor(FindInFilesAction, VIEW_ID, nls.localize('showSearchViewl', "Show Search"), { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_F }, Constants.SearchViewVisibleKey.toNegated()), 'View: Show Search', nls.localize('view', "View")); registry.registerWorkbenchAction(new SyncActionDescriptor(FindInFilesAction, VIEW_ID, nls.localize('showSearchViewl', "Show Search"), { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_F }, Constants.SearchViewVisibleKey.toNegated()), 'View: Show Search', nls.localize('view', "View"));
registry.registerWorkbenchAction(new SyncActionDescriptor(FindInFilesAction, Constants.FindInFilesActionId, nls.localize('findInFiles', "Find in Files"), { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_F }), 'Find in Files', category); registry.registerWorkbenchAction(new SyncActionDescriptor(FindInFilesAction, Constants.FindInFilesActionId, nls.localize('findInFiles', "Find in Files"), { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_F }), 'Find in Files', category);
MenuRegistry.appendMenuItem(MenuId.MenubarEditMenu, {
group: '4_find_global',
command: {
id: Constants.FindInFilesActionId,
title: nls.localize({ key: 'miFindInFiles', comment: ['&& denotes a mnemonic'] }, "Find &&in Files")
},
order: 1
});
registry.registerWorkbenchAction(new SyncActionDescriptor(FocusNextSearchResultAction, FocusNextSearchResultAction.ID, FocusNextSearchResultAction.LABEL, { primary: KeyCode.F4 }, ContextKeyExpr.and(Constants.HasSearchResults)), 'Focus Next Search Result', category); registry.registerWorkbenchAction(new SyncActionDescriptor(FocusNextSearchResultAction, FocusNextSearchResultAction.ID, FocusNextSearchResultAction.LABEL, { primary: KeyCode.F4 }, ContextKeyExpr.and(Constants.HasSearchResults)), 'Focus Next Search Result', category);
registry.registerWorkbenchAction(new SyncActionDescriptor(FocusPreviousSearchResultAction, FocusPreviousSearchResultAction.ID, FocusPreviousSearchResultAction.LABEL, { primary: KeyMod.Shift | KeyCode.F4 }, ContextKeyExpr.and(Constants.HasSearchResults)), 'Focus Previous Search Result', category); registry.registerWorkbenchAction(new SyncActionDescriptor(FocusPreviousSearchResultAction, FocusPreviousSearchResultAction.ID, FocusPreviousSearchResultAction.LABEL, { primary: KeyMod.Shift | KeyCode.F4 }, ContextKeyExpr.and(Constants.HasSearchResults)), 'Focus Previous Search Result', category);
registry.registerWorkbenchAction(new SyncActionDescriptor(ReplaceInFilesAction, ReplaceInFilesAction.ID, ReplaceInFilesAction.LABEL, { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_H }), 'Replace in Files', category); registry.registerWorkbenchAction(new SyncActionDescriptor(ReplaceInFilesAction, ReplaceInFilesAction.ID, ReplaceInFilesAction.LABEL, { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_H }), 'Replace in Files', category);
MenuRegistry.appendMenuItem(MenuId.MenubarEditMenu, {
group: '4_find_global',
command: {
id: ReplaceInFilesAction.ID,
title: nls.localize({ key: 'miReplaceInFiles', comment: ['&& denotes a mnemonic'] }, "Replace &&in Files")
},
order: 2
});
KeybindingsRegistry.registerCommandAndKeybindingRule(objects.assign({ KeybindingsRegistry.registerCommandAndKeybindingRule(objects.assign({
id: Constants.ToggleCaseSensitiveCommandId, id: Constants.ToggleCaseSensitiveCommandId,