未验证 提交 524bf8be 编写于 作者: S Sandeep Somavarapu 提交者: GitHub

Merge pull request #41567 from Digized/master

Add copy command action to keybinding editor context menu
......@@ -26,7 +26,7 @@ import { SearchWidget } from 'vs/workbench/parts/preferences/browser/preferences
import { DefineKeybindingWidget } from 'vs/workbench/parts/preferences/browser/keybindingWidgets';
import {
IPreferencesService, IKeybindingsEditor, CONTEXT_KEYBINDING_FOCUS, CONTEXT_KEYBINDINGS_EDITOR, CONTEXT_KEYBINDINGS_SEARCH_FOCUS, KEYBINDINGS_EDITOR_COMMAND_REMOVE, KEYBINDINGS_EDITOR_COMMAND_COPY,
KEYBINDINGS_EDITOR_COMMAND_RESET, KEYBINDINGS_EDITOR_COMMAND_DEFINE, KEYBINDINGS_EDITOR_COMMAND_SHOW_CONFLICTS
KEYBINDINGS_EDITOR_COMMAND_RESET, KEYBINDINGS_EDITOR_COMMAND_COPY_COMMAND, KEYBINDINGS_EDITOR_COMMAND_DEFINE, KEYBINDINGS_EDITOR_COMMAND_SHOW_CONFLICTS
} from 'vs/workbench/parts/preferences/common/preferences';
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { IKeybindingEditingService } from 'vs/workbench/services/keybinding/common/keybindingEditing';
......@@ -245,6 +245,13 @@ export class KeybindingsEditor extends BaseEditor implements IKeybindingsEditor
return TPromise.as(null);
}
copyKeybindingCommand(keybinding: IKeybindingItemEntry): TPromise<any> {
this.selectEntry(keybinding);
this.reportKeybindingAction(KEYBINDINGS_EDITOR_COMMAND_COPY_COMMAND, keybinding.keybindingItem.command, keybinding.keybindingItem.keybinding);
this.clipboardService.writeText(keybinding.keybindingItem.command);
return TPromise.as(null);
}
search(filter: string): void {
this.searchWidget.focus();
}
......@@ -456,6 +463,7 @@ export class KeybindingsEditor extends BaseEditor implements IKeybindingsEditor
getAnchor: () => e.anchor,
getActions: () => TPromise.as([
this.createCopyAction(<IKeybindingItemEntry>e.element),
this.createCopyCommandAction(<IKeybindingItemEntry>e.element),
new Separator(),
this.createDefineAction(<IKeybindingItemEntry>e.element),
this.createRemoveAction(<IKeybindingItemEntry>e.element),
......@@ -526,6 +534,15 @@ export class KeybindingsEditor extends BaseEditor implements IKeybindingsEditor
};
}
private createCopyCommandAction(keybinding: IKeybindingItemEntry): IAction {
return <IAction>{
label: localize('copyCommandLabel', "Copy Command"),
enabled: true,
id: KEYBINDINGS_EDITOR_COMMAND_COPY_COMMAND,
run: () => this.copyKeybindingCommand(keybinding)
};
}
private reportFilteringUsed(filter: string): void {
if (filter) {
let data = {
......
......@@ -149,6 +149,7 @@ export interface IKeybindingsEditor extends IEditor {
removeKeybinding(keybindingEntry: IKeybindingItemEntry): TPromise<any>;
resetKeybinding(keybindingEntry: IKeybindingItemEntry): TPromise<any>;
copyKeybinding(keybindingEntry: IKeybindingItemEntry): TPromise<any>;
copyKeybindingCommand(keybindingEntry: IKeybindingItemEntry): TPromise<any>;
showConflicts(keybindingEntry: IKeybindingItemEntry): TPromise<any>;
}
......@@ -202,6 +203,7 @@ export const KEYBINDINGS_EDITOR_COMMAND_DEFINE = 'keybindings.editor.defineKeybi
export const KEYBINDINGS_EDITOR_COMMAND_REMOVE = 'keybindings.editor.removeKeybinding';
export const KEYBINDINGS_EDITOR_COMMAND_RESET = 'keybindings.editor.resetKeybinding';
export const KEYBINDINGS_EDITOR_COMMAND_COPY = 'keybindings.editor.copyKeybindingEntry';
export const KEYBINDINGS_EDITOR_COMMAND_COPY_COMMAND = 'keybindings.editor.copyCommandKeybindingEntry';
export const KEYBINDINGS_EDITOR_COMMAND_SHOW_CONFLICTS = 'keybindings.editor.showConflicts';
export const KEYBINDINGS_EDITOR_COMMAND_FOCUS_KEYBINDINGS = 'keybindings.editor.focusKeybindings';
......
......@@ -19,7 +19,7 @@ import { KeybindingsEditor, KeybindingsEditorInput } from 'vs/workbench/parts/pr
import { OpenRawDefaultSettingsAction, OpenGlobalSettingsAction, OpenGlobalKeybindingsAction, OpenGlobalKeybindingsFileAction, OpenWorkspaceSettingsAction, OpenFolderSettingsAction, ConfigureLanguageBasedSettingsAction, OPEN_FOLDER_SETTINGS_COMMAND } from 'vs/workbench/parts/preferences/browser/preferencesActions';
import {
IPreferencesService, IKeybindingsEditor, IPreferencesSearchService, CONTEXT_KEYBINDING_FOCUS, CONTEXT_KEYBINDINGS_EDITOR, CONTEXT_KEYBINDINGS_SEARCH_FOCUS, KEYBINDINGS_EDITOR_COMMAND_DEFINE, KEYBINDINGS_EDITOR_COMMAND_REMOVE, KEYBINDINGS_EDITOR_COMMAND_SEARCH,
KEYBINDINGS_EDITOR_COMMAND_COPY, KEYBINDINGS_EDITOR_COMMAND_RESET, KEYBINDINGS_EDITOR_COMMAND_SHOW_CONFLICTS, KEYBINDINGS_EDITOR_COMMAND_FOCUS_KEYBINDINGS, KEYBINDINGS_EDITOR_COMMAND_CLEAR_SEARCH_RESULTS
KEYBINDINGS_EDITOR_COMMAND_COPY, KEYBINDINGS_EDITOR_COMMAND_RESET, KEYBINDINGS_EDITOR_COMMAND_COPY_COMMAND, KEYBINDINGS_EDITOR_COMMAND_SHOW_CONFLICTS, KEYBINDINGS_EDITOR_COMMAND_FOCUS_KEYBINDINGS, KEYBINDINGS_EDITOR_COMMAND_CLEAR_SEARCH_RESULTS
} from 'vs/workbench/parts/preferences/common/preferences';
import { PreferencesService } from 'vs/workbench/parts/preferences/browser/preferencesService';
import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
......@@ -238,6 +238,17 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
}
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: KEYBINDINGS_EDITOR_COMMAND_COPY_COMMAND,
weight: KeybindingsRegistry.WEIGHT.workbenchContrib(),
when: ContextKeyExpr.and(CONTEXT_KEYBINDINGS_EDITOR, CONTEXT_KEYBINDING_FOCUS),
primary: null,
handler: (accessor, args: any) => {
const editor = accessor.get(IWorkbenchEditorService).getActiveEditor() as IKeybindingsEditor;
editor.copyKeybindingCommand(editor.activeKeybindingEntry);
}
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: KEYBINDINGS_EDITOR_COMMAND_FOCUS_KEYBINDINGS,
weight: KeybindingsRegistry.WEIGHT.workbenchContrib(),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册