Clean up editor commands
This commit is contained in:
parent
61b42f7332
commit
acea018800
|
@ -4,20 +4,130 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import {TPromise} from 'vs/base/common/winjs.base';
|
||||
import {KeyCode, KeyMod} from 'vs/base/common/keyCodes';
|
||||
import {IEditorService} from 'vs/platform/editor/common/editor';
|
||||
import {ServicesAccessor} from 'vs/platform/instantiation/common/instantiation';
|
||||
import {IKeybindings, KbExpr} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {ICommandDescriptor, KeybindingsRegistry} from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||
import {ICommandHandlerDescription} from 'vs/platform/commands/common/commands';
|
||||
import {ICommandAndKeybindingRule, KeybindingsRegistry} from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||
import * as editorCommon from 'vs/editor/common/editorCommon';
|
||||
import {ICodeEditorService} from 'vs/editor/common/services/codeEditorService';
|
||||
import {ICommandHandler} from 'vs/platform/commands/common/commands';
|
||||
import {CommandsRegistry, ICommandHandler, ICommandHandlerDescription} from 'vs/platform/commands/common/commands';
|
||||
|
||||
import H = editorCommon.Handler;
|
||||
import D = editorCommon.CommandDescription;
|
||||
import EditorKbExpr = editorCommon.EditorKbExpr;
|
||||
|
||||
export interface IKeybindingsOptions {
|
||||
kbExpr?: KbExpr;
|
||||
weight?: number;
|
||||
}
|
||||
|
||||
export interface ICommandKeybindingsOptions extends IKeybindings, IKeybindingsOptions {
|
||||
}
|
||||
|
||||
export abstract class Command {
|
||||
public id: string;
|
||||
public kbOpts: ICommandKeybindingsOptions;
|
||||
|
||||
constructor(id:string) {
|
||||
this.id = id;
|
||||
this.kbOpts = null;
|
||||
}
|
||||
|
||||
public abstract runCommand(accessor:ServicesAccessor, args: any): void | TPromise<void>;
|
||||
|
||||
public toCommandAndKeybindingRule(defaultWeight:number): ICommandAndKeybindingRule {
|
||||
const kbOpts = this.kbOpts || { primary: 0 };
|
||||
return {
|
||||
id: this.id,
|
||||
handler: (accessor, args) => this.runCommand(accessor, args),
|
||||
weight: kbOpts.weight || defaultWeight,
|
||||
when: kbOpts.kbExpr,
|
||||
primary: kbOpts.primary,
|
||||
secondary: kbOpts.secondary,
|
||||
win: kbOpts.win,
|
||||
linux: kbOpts.linux,
|
||||
mac: kbOpts.mac,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export interface EditorControllerCommand<T extends editorCommon.IEditorContribution> {
|
||||
new(id:string, callback:(controller:T)=>void, keybindings:ICommandKeybindingsOptions): EditorCommand;
|
||||
}
|
||||
|
||||
export abstract class EditorCommand extends Command {
|
||||
|
||||
public static bindToContribution<T extends editorCommon.IEditorContribution>(controllerGetter:(editor:editorCommon.ICommonCodeEditor) => T, defaults?:IKeybindingsOptions): EditorControllerCommand<T> {
|
||||
|
||||
const defaultWeight = defaults ? defaults.weight || 0 : 0;
|
||||
const defaultKbExpr = defaults ? defaults.kbExpr || null : null;
|
||||
|
||||
return class EditorControllerCommandImpl extends EditorCommand {
|
||||
private _callback:(controller:T)=>void;
|
||||
|
||||
constructor(id:string, callback:(controller:T)=>void, keybindings:ICommandKeybindingsOptions) {
|
||||
super(id);
|
||||
|
||||
this._callback = callback;
|
||||
|
||||
this.kbOpts = {
|
||||
weight: keybindings.weight || defaultWeight,
|
||||
kbExpr: keybindings.kbExpr || defaultKbExpr,
|
||||
primary: keybindings.primary,
|
||||
secondary: keybindings.secondary,
|
||||
win: keybindings.win,
|
||||
linux: keybindings.linux,
|
||||
mac: keybindings.mac,
|
||||
};
|
||||
}
|
||||
|
||||
protected runEditorCommand(accessor:ServicesAccessor, editor: editorCommon.ICommonCodeEditor, args: any): void {
|
||||
this._callback(controllerGetter(editor));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
constructor(id:string) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
public runCommand(accessor:ServicesAccessor, args: any): void | TPromise<void> {
|
||||
let editor = findFocusedEditor(this.id, accessor, false);
|
||||
if (!editor) {
|
||||
editor = getActiveEditor(accessor);
|
||||
}
|
||||
if (!editor) {
|
||||
// well, at least we tried...
|
||||
return;
|
||||
}
|
||||
return this.runEditorCommand(accessor, editor, args);
|
||||
}
|
||||
|
||||
protected abstract runEditorCommand(accessor:ServicesAccessor, editor: editorCommon.ICommonCodeEditor, args: any): void | TPromise<void>;
|
||||
}
|
||||
|
||||
class CoreCommand extends Command {
|
||||
constructor(handlerId:string, weight: number, kbExpr: KbExpr, kb: IKeybindings) {
|
||||
super(handlerId);
|
||||
|
||||
this.kbOpts = {
|
||||
weight: weight,
|
||||
kbExpr: kbExpr,
|
||||
primary: kb.primary,
|
||||
secondary: kb.secondary,
|
||||
win: kb.win,
|
||||
linux: kb.linux,
|
||||
mac: kb.mac,
|
||||
};
|
||||
}
|
||||
|
||||
public runCommand(accessor:ServicesAccessor, args: any): void {
|
||||
triggerEditorHandler(this.id, accessor, args);
|
||||
}
|
||||
}
|
||||
|
||||
export function findFocusedEditor(commandId: string, accessor: ServicesAccessor, complain: boolean): editorCommon.ICommonCodeEditor {
|
||||
let editor = accessor.get(ICodeEditorService).getFocusedCodeEditor();
|
||||
if (!editor) {
|
||||
|
@ -29,14 +139,14 @@ export function findFocusedEditor(commandId: string, accessor: ServicesAccessor,
|
|||
return editor;
|
||||
}
|
||||
|
||||
export function withCodeEditorFromCommandHandler(commandId: string, accessor: ServicesAccessor, callback: (editor:editorCommon.ICommonCodeEditor) => void): void {
|
||||
function withCodeEditorFromCommandHandler(commandId: string, accessor: ServicesAccessor, callback: (editor:editorCommon.ICommonCodeEditor) => void): void {
|
||||
let editor = findFocusedEditor(commandId, accessor, true);
|
||||
if (editor) {
|
||||
callback(editor);
|
||||
}
|
||||
}
|
||||
|
||||
export function getActiveEditor(accessor: ServicesAccessor): editorCommon.ICommonCodeEditor {
|
||||
function getActiveEditor(accessor: ServicesAccessor): editorCommon.ICommonCodeEditor {
|
||||
let editorService = accessor.get(IEditorService);
|
||||
let activeEditor = (<any>editorService).getActiveEditor && (<any>editorService).getActiveEditor();
|
||||
if (activeEditor) {
|
||||
|
@ -58,40 +168,26 @@ function triggerEditorHandler(handlerId: string, accessor: ServicesAccessor, arg
|
|||
});
|
||||
}
|
||||
|
||||
function registerCoreCommand(handlerId: string, kb: IKeybindings, weight?: number, when?: KbExpr, description?: ICommandHandlerDescription): void {
|
||||
let desc: ICommandDescriptor = {
|
||||
id: handlerId,
|
||||
function registerCoreCommand(handlerId: string, kb: IKeybindings, weight?: number, when?: KbExpr): void {
|
||||
let command = new CoreCommand(
|
||||
handlerId,
|
||||
weight,
|
||||
when ? when : EditorKbExpr.TextFocus,
|
||||
kb
|
||||
);
|
||||
KeybindingsRegistry.registerCommandAndKeybindingRule(command.toCommandAndKeybindingRule(KeybindingsRegistry.WEIGHT.editorCore()));
|
||||
}
|
||||
|
||||
function registerCoreAPICommand(handlerId: string, description: ICommandHandlerDescription): void {
|
||||
CommandsRegistry.registerCommand(handlerId, {
|
||||
handler: triggerEditorHandler.bind(null, handlerId),
|
||||
weight: weight ? weight : KeybindingsRegistry.WEIGHT.editorCore(),
|
||||
when: (when ? when : EditorKbExpr.TextFocus),
|
||||
primary: kb.primary,
|
||||
secondary: kb.secondary,
|
||||
win: kb.win,
|
||||
mac: kb.mac,
|
||||
linux: kb.linux,
|
||||
description: description
|
||||
};
|
||||
KeybindingsRegistry.registerCommandDesc(desc);
|
||||
});
|
||||
}
|
||||
|
||||
function registerOverwritableCommand(handlerId:string, handler:ICommandHandler): void {
|
||||
let desc: ICommandDescriptor = {
|
||||
id: handlerId,
|
||||
handler: handler,
|
||||
weight: KeybindingsRegistry.WEIGHT.editorCore(),
|
||||
when: null,
|
||||
primary: 0
|
||||
};
|
||||
KeybindingsRegistry.registerCommandDesc(desc);
|
||||
|
||||
let desc2: ICommandDescriptor = {
|
||||
id: 'default:' + handlerId,
|
||||
handler: handler,
|
||||
weight: KeybindingsRegistry.WEIGHT.editorCore(),
|
||||
when: null,
|
||||
primary: 0
|
||||
};
|
||||
KeybindingsRegistry.registerCommandDesc(desc2);
|
||||
CommandsRegistry.registerCommand(handlerId, handler);
|
||||
CommandsRegistry.registerCommand('default:' + handlerId, handler);
|
||||
}
|
||||
|
||||
function registerCoreDispatchCommand(handlerId: string): void {
|
||||
|
@ -163,7 +259,7 @@ function getWordNavigationKB(shift:boolean, key:KeyCode): number {
|
|||
// Control+Command+shift+d => noop
|
||||
|
||||
// Register cursor commands
|
||||
registerCoreCommand(H.CursorMove, { primary: null }, null, null, D.CursorMove);
|
||||
registerCoreAPICommand(H.CursorMove, D.CursorMove);
|
||||
|
||||
registerCoreCommand(H.CursorLeft, {
|
||||
primary: KeyCode.LeftArrow,
|
||||
|
@ -232,7 +328,7 @@ registerCoreCommand(H.ExpandLineSelection, {
|
|||
primary: KeyMod.CtrlCmd | KeyCode.KEY_I
|
||||
});
|
||||
|
||||
registerCoreCommand(H.EditorScroll, { primary: null }, null, null, D.EditorScroll);
|
||||
registerCoreAPICommand(H.EditorScroll, D.EditorScroll);
|
||||
|
||||
registerCoreCommand(H.ScrollLineUp, {
|
||||
primary: KeyMod.CtrlCmd | KeyCode.UpArrow,
|
||||
|
@ -415,7 +511,7 @@ function selectAll(accessor: ServicesAccessor, args: any): void {
|
|||
return;
|
||||
}
|
||||
}
|
||||
KeybindingsRegistry.registerCommandDesc({
|
||||
KeybindingsRegistry.registerCommandAndKeybindingRule({
|
||||
id: 'editor.action.selectAll',
|
||||
handler: selectAll,
|
||||
weight: KeybindingsRegistry.WEIGHT.editorCore(),
|
||||
|
|
|
@ -8,20 +8,20 @@ import {illegalArgument} from 'vs/base/common/errors';
|
|||
import URI from 'vs/base/common/uri';
|
||||
import {TPromise} from 'vs/base/common/winjs.base';
|
||||
import {ServicesAccessor, IInstantiationService} from 'vs/platform/instantiation/common/instantiation';
|
||||
import {IKeybindings, KbExpr} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {ICommandHandler} from 'vs/platform/commands/common/commands';
|
||||
import {ICommandDescriptor, KeybindingsRegistry} from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||
import {KbExpr} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {CommandsRegistry} from 'vs/platform/commands/common/commands';
|
||||
import {KeybindingsRegistry} from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||
import {Registry} from 'vs/platform/platform';
|
||||
import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry';
|
||||
import {findFocusedEditor, getActiveEditor, withCodeEditorFromCommandHandler} from 'vs/editor/common/config/config';
|
||||
import {Command as ConfigBasicCommand, EditorCommand as ConfigEditorCommand} from 'vs/editor/common/config/config';
|
||||
import {Position} from 'vs/editor/common/core/position';
|
||||
import * as editorCommon from 'vs/editor/common/editorCommon';
|
||||
import {IModelService} from 'vs/editor/common/services/modelService';
|
||||
import {MenuId, MenuRegistry} from 'vs/platform/actions/common/actions';
|
||||
|
||||
import EditorKbExpr = editorCommon.EditorKbExpr;
|
||||
|
||||
export type ServicesAccessor = ServicesAccessor;
|
||||
export const Command = ConfigBasicCommand;
|
||||
export const EditorCommand = ConfigEditorCommand;
|
||||
|
||||
// --- Keybinding extensions to make it more concise to express keybindings conditions
|
||||
export interface IEditorCommandMenuOptions {
|
||||
|
@ -33,10 +33,6 @@ export interface IEditorCommandMenuOptions {
|
|||
|
||||
// --- Editor Actions
|
||||
|
||||
export interface IEditorCommandHandler {
|
||||
(accessor:ServicesAccessor, editor: editorCommon.ICommonCodeEditor, args: any): void;
|
||||
}
|
||||
|
||||
export module CommonEditorRegistry {
|
||||
|
||||
export function registerEditorAction(desc:EditorAction) {
|
||||
|
@ -60,36 +56,12 @@ export module CommonEditorRegistry {
|
|||
return KeybindingsRegistry.WEIGHT.editorContrib(importance);
|
||||
}
|
||||
|
||||
export function registerEditorCommand(commandId: string, weight: number, keybinding:IKeybindings, needsTextFocus: boolean, needsKey: string, handler: IEditorCommandHandler): void {
|
||||
var commandDesc: ICommandDescriptor = {
|
||||
id: commandId,
|
||||
handler: createCommandHandler(commandId, handler),
|
||||
weight: weight,
|
||||
when: whenRule(needsTextFocus, needsKey),
|
||||
primary: keybinding.primary,
|
||||
secondary: keybinding.secondary,
|
||||
win: keybinding.win,
|
||||
linux: keybinding.linux,
|
||||
mac: keybinding.mac,
|
||||
};
|
||||
|
||||
KeybindingsRegistry.registerCommandDesc(commandDesc);
|
||||
}
|
||||
|
||||
export function registerEditorCommand2(desc: EditorCommand): void {
|
||||
KeybindingsRegistry.registerCommandDesc(desc.toCommandDescriptor(KeybindingsRegistry.WEIGHT.editorContrib()));
|
||||
export function registerEditorCommand2(desc: ConfigBasicCommand): void {
|
||||
KeybindingsRegistry.registerCommandAndKeybindingRule(desc.toCommandAndKeybindingRule(KeybindingsRegistry.WEIGHT.editorContrib()));
|
||||
}
|
||||
|
||||
export function registerLanguageCommand(id: string, handler: (accessor: ServicesAccessor, args: { [n: string]: any }) => any) {
|
||||
KeybindingsRegistry.registerCommandDesc({
|
||||
id,
|
||||
handler(accessor, args: any) {
|
||||
return handler(accessor, args || {});
|
||||
},
|
||||
weight: KeybindingsRegistry.WEIGHT.editorContrib(),
|
||||
primary: undefined,
|
||||
when: undefined,
|
||||
});
|
||||
CommandsRegistry.registerCommand(id, (accessor, args) => handler(accessor, args || {}));
|
||||
}
|
||||
|
||||
export function registerDefaultLanguageCommand(id: string, handler: (model: editorCommon.IModel, position: Position, args: { [n: string]: any }) => any) {
|
||||
|
@ -157,7 +129,7 @@ class EditorContributionRegistry {
|
|||
});
|
||||
}
|
||||
|
||||
KeybindingsRegistry.registerCommandDesc(action.toCommandDescriptor(KeybindingsRegistry.WEIGHT.editorContrib()));
|
||||
KeybindingsRegistry.registerCommandAndKeybindingRule(action.toCommandAndKeybindingRule(KeybindingsRegistry.WEIGHT.editorContrib()));
|
||||
|
||||
this.editorActions.push(action);
|
||||
}
|
||||
|
@ -172,109 +144,7 @@ class EditorContributionRegistry {
|
|||
}
|
||||
Registry.add(Extensions.EditorCommonContributions, new EditorContributionRegistry());
|
||||
|
||||
export function whenRule(needsTextFocus: boolean, needsKey: string): KbExpr {
|
||||
|
||||
let base = (needsTextFocus ? EditorKbExpr.TextFocus : EditorKbExpr.Focus);
|
||||
|
||||
if (needsKey) {
|
||||
return KbExpr.and(base, KbExpr.has(needsKey));
|
||||
}
|
||||
|
||||
return base;
|
||||
}
|
||||
|
||||
function createCommandHandler(commandId: string, handler: IEditorCommandHandler): ICommandHandler {
|
||||
return (accessor, args) => {
|
||||
withCodeEditorFromCommandHandler(commandId, accessor, (editor) => {
|
||||
handler(accessor, editor, args||{});
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export interface IEditorActionKeybindingOptions2 extends IKeybindings {
|
||||
kbExpr?: KbExpr;
|
||||
weight?: number;
|
||||
}
|
||||
|
||||
export abstract class Command {
|
||||
public id: string;
|
||||
public kbOpts: IEditorActionKeybindingOptions2;
|
||||
|
||||
constructor(id:string) {
|
||||
this.id = id;
|
||||
this.kbOpts = null;
|
||||
}
|
||||
|
||||
public abstract runCommand(accessor:ServicesAccessor, args: any): void | TPromise<void>;
|
||||
|
||||
public toCommandDescriptor(defaultWeight:number): ICommandDescriptor {
|
||||
const kbOpts = this.kbOpts || { primary: 0 };
|
||||
return {
|
||||
id: this.id,
|
||||
handler: (accessor, args) => this.runCommand(accessor, args),
|
||||
weight: kbOpts.weight || defaultWeight,
|
||||
when: kbOpts.kbExpr,
|
||||
primary: kbOpts.primary,
|
||||
secondary: kbOpts.secondary,
|
||||
win: kbOpts.win,
|
||||
linux: kbOpts.linux,
|
||||
mac: kbOpts.mac,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export interface EditorControllerCommand<T extends editorCommon.IEditorContribution> {
|
||||
new(id:string, callback:(controller:T)=>void, keybindings:IKeybindings): EditorCommand;
|
||||
}
|
||||
|
||||
export abstract class EditorCommand extends Command {
|
||||
|
||||
public static bindToContribution<T extends editorCommon.IEditorContribution>(controllerGetter:(editor:editorCommon.ICommonCodeEditor) => T, weight: number, kbExpr: KbExpr): EditorControllerCommand<T> {
|
||||
return class EditorControllerCommandImpl extends EditorCommand {
|
||||
private _callback:(controller:T)=>void;
|
||||
|
||||
constructor(id:string, callback:(controller:T)=>void, keybindings:IKeybindings) {
|
||||
super(id);
|
||||
|
||||
this._callback = callback;
|
||||
|
||||
this.kbOpts = {
|
||||
weight: weight,
|
||||
kbExpr: kbExpr,
|
||||
primary: keybindings.primary,
|
||||
secondary: keybindings.secondary,
|
||||
win: keybindings.win,
|
||||
linux: keybindings.linux,
|
||||
mac: keybindings.mac,
|
||||
};
|
||||
}
|
||||
|
||||
protected runEditorCommand(accessor:ServicesAccessor, editor: editorCommon.ICommonCodeEditor, args: any): void {
|
||||
this._callback(controllerGetter(editor));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
constructor(id:string) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
public runCommand(accessor:ServicesAccessor, args: any): void | TPromise<void> {
|
||||
let editor = findFocusedEditor(this.id, accessor, false);
|
||||
if (!editor) {
|
||||
editor = getActiveEditor(accessor);
|
||||
}
|
||||
if (!editor) {
|
||||
// well, at least we tried...
|
||||
return;
|
||||
}
|
||||
return this.runEditorCommand(accessor, editor, args);
|
||||
}
|
||||
|
||||
protected abstract runEditorCommand(accessor:ServicesAccessor, editor: editorCommon.ICommonCodeEditor, args: any): void | TPromise<void>;
|
||||
}
|
||||
|
||||
export abstract class EditorAction extends EditorCommand {
|
||||
export abstract class EditorAction extends ConfigEditorCommand {
|
||||
|
||||
private _needsWritableEditor: boolean;
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ import {KbExpr, KbCtxKey, IKeybindingContextKey, IKeybindingService} from 'vs/pl
|
|||
import {KeybindingsRegistry} from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||
import {GlobalScreenReaderNVDA} from 'vs/editor/common/config/commonEditorConfig';
|
||||
import {ICommonCodeEditor, IEditorContribution, EditorKbExpr, SHOW_ACCESSIBILITY_HELP_ACTION_ID} from 'vs/editor/common/editorCommon';
|
||||
import {CommonEditorRegistry, EditorAction, EditorCommand} from 'vs/editor/common/editorCommonExtensions';
|
||||
import {CommonEditorRegistry, EditorAction, EditorCommand, Command} from 'vs/editor/common/editorCommonExtensions';
|
||||
import {ICodeEditor, IOverlayWidget, IOverlayWidgetPosition} from 'vs/editor/browser/editorBrowser';
|
||||
import {EditorBrowserRegistry} from 'vs/editor/browser/editorBrowserExtensions';
|
||||
import {ToggleTabFocusModeAction} from 'vs/editor/contrib/toggleTabFocusMode/common/toggleTabFocusMode';
|
||||
|
@ -216,8 +216,10 @@ CommonEditorRegistry.registerEditorAction(new ShowAccessibilityHelpAction());
|
|||
|
||||
const AccessibilityHelpCommand = EditorCommand.bindToContribution<AccessibilityHelpController>(
|
||||
AccessibilityHelpController.get,
|
||||
CommonEditorRegistry.commandWeight(100),
|
||||
KbExpr.and(EditorKbExpr.Focus, CONTEXT_ACCESSIBILITY_WIDGET_VISIBLE)
|
||||
{
|
||||
weight: CommonEditorRegistry.commandWeight(100),
|
||||
kbExpr: KbExpr.and(EditorKbExpr.Focus, CONTEXT_ACCESSIBILITY_WIDGET_VISIBLE)
|
||||
}
|
||||
);
|
||||
|
||||
CommonEditorRegistry.registerEditorCommand2(new AccessibilityHelpCommand(
|
||||
|
@ -227,13 +229,22 @@ CommonEditorRegistry.registerEditorCommand2(new AccessibilityHelpCommand(
|
|||
primary: KeyCode.Escape, secondary: [KeyMod.Shift | KeyCode.Escape]
|
||||
}
|
||||
));
|
||||
KeybindingsRegistry.registerCommandDesc({
|
||||
id: TOGGLE_EXPERIMENTAL_SCREEN_READER_SUPPORT_COMMAND_ID,
|
||||
handler: (accessor: ServicesAccessor) => {
|
||||
|
||||
class ToggleExperimentalScreenReaderSupportCommand extends Command {
|
||||
constructor() {
|
||||
super(TOGGLE_EXPERIMENTAL_SCREEN_READER_SUPPORT_COMMAND_ID);
|
||||
|
||||
this.kbOpts = {
|
||||
weight: KeybindingsRegistry.WEIGHT.workbenchContrib(),
|
||||
kbExpr: null,
|
||||
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_R
|
||||
};
|
||||
}
|
||||
|
||||
public runCommand(accessor:ServicesAccessor, args: any): void {
|
||||
let currentValue = GlobalScreenReaderNVDA.getValue();
|
||||
GlobalScreenReaderNVDA.setValue(!currentValue);
|
||||
},
|
||||
weight: KeybindingsRegistry.WEIGHT.workbenchContrib(),
|
||||
when: null,
|
||||
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_R
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
CommonEditorRegistry.registerEditorCommand2(new ToggleExperimentalScreenReaderSupportCommand());
|
||||
|
|
|
@ -38,7 +38,6 @@ abstract class ExecCommandAction extends EditorAction {
|
|||
}
|
||||
|
||||
document.execCommand(this.browserCommand);
|
||||
|
||||
}
|
||||
|
||||
public run(accessor:ServicesAccessor, editor:editorCommon.ICommonCodeEditor): void {
|
||||
|
|
|
@ -877,15 +877,17 @@ CommonEditorRegistry.registerEditorAction(new AddSelectionToNextFindMatchAction(
|
|||
CommonEditorRegistry.registerEditorAction(new AddSelectionToPreviousFindMatchAction());
|
||||
|
||||
const FindCommand = EditorCommand.bindToContribution<CommonFindController>(
|
||||
CommonFindController.getFindController,
|
||||
CommonEditorRegistry.commandWeight(5),
|
||||
EditorKbExpr.Focus
|
||||
CommonFindController.getFindController, {
|
||||
weight: CommonEditorRegistry.commandWeight(5),
|
||||
kbExpr: EditorKbExpr.Focus
|
||||
}
|
||||
);
|
||||
|
||||
const VisibleWidgetFindCommand = EditorCommand.bindToContribution(
|
||||
CommonFindController.getFindController,
|
||||
CommonEditorRegistry.commandWeight(5),
|
||||
KbExpr.and(EditorKbExpr.Focus, CONTEXT_FIND_WIDGET_VISIBLE)
|
||||
CommonFindController.getFindController, {
|
||||
weight: CommonEditorRegistry.commandWeight(5),
|
||||
kbExpr: KbExpr.and(EditorKbExpr.Focus, CONTEXT_FIND_WIDGET_VISIBLE)
|
||||
}
|
||||
);
|
||||
|
||||
CommonEditorRegistry.registerEditorCommand2(new VisibleWidgetFindCommand(
|
||||
|
|
|
@ -547,9 +547,10 @@ class PrevMarkerAction extends MarkerNavigationAction {
|
|||
var CONTEXT_MARKERS_NAVIGATION_VISIBLE = new KbCtxKey('markersNavigationVisible');
|
||||
|
||||
const MarkerCommand = EditorCommand.bindToContribution<MarkerController>(
|
||||
MarkerController.getMarkerController,
|
||||
CommonEditorRegistry.commandWeight(50),
|
||||
KbExpr.and(EditorKbExpr.Focus, CONTEXT_MARKERS_NAVIGATION_VISIBLE)
|
||||
MarkerController.getMarkerController, {
|
||||
weight: CommonEditorRegistry.commandWeight(50),
|
||||
kbExpr: KbExpr.and(EditorKbExpr.Focus, CONTEXT_MARKERS_NAVIGATION_VISIBLE)
|
||||
}
|
||||
);
|
||||
|
||||
// register actions
|
||||
|
|
|
@ -10,9 +10,7 @@ import { dispose } from 'vs/base/common/lifecycle';
|
|||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { ICommonCodeEditor, IEditorContribution, EditorKbExpr } from 'vs/editor/common/editorCommon';
|
||||
import { KbExpr } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||
import { withCodeEditorFromCommandHandler } from 'vs/editor/common/config/config';
|
||||
import { ServicesAccessor, EditorAction, CommonEditorRegistry } from 'vs/editor/common/editorCommonExtensions';
|
||||
import { ServicesAccessor, EditorAction, EditorCommand, CommonEditorRegistry } from 'vs/editor/common/editorCommonExtensions';
|
||||
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import { EditorBrowserRegistry } from 'vs/editor/browser/editorBrowserExtensions';
|
||||
import { SignatureHelpProviderRegistry } from 'vs/editor/common/modes';
|
||||
|
@ -90,41 +88,47 @@ export class TriggerParameterHintsAction extends EditorAction {
|
|||
|
||||
const weight = CommonEditorRegistry.commandWeight(75);
|
||||
|
||||
function handler(id: string, fn: (controller: ParameterHintsController) => void) {
|
||||
return accessor => withCodeEditorFromCommandHandler(id, accessor, editor => {
|
||||
fn(ParameterHintsController.get(editor));
|
||||
});
|
||||
}
|
||||
const ParameterHintsCommand = EditorCommand.bindToContribution(
|
||||
ParameterHintsController.get, {
|
||||
weight: weight,
|
||||
kbExpr: KbExpr.and(EditorKbExpr.TextFocus, Context.Visible)
|
||||
}
|
||||
);
|
||||
const MultipleSignaturesParameterHintsCommand = EditorCommand.bindToContribution(
|
||||
ParameterHintsController.get, {
|
||||
weight: weight,
|
||||
kbExpr: KbExpr.and(EditorKbExpr.TextFocus, Context.Visible, Context.MultipleSignatures)
|
||||
}
|
||||
);
|
||||
|
||||
EditorBrowserRegistry.registerEditorContribution(ParameterHintsController);
|
||||
|
||||
CommonEditorRegistry.registerEditorAction(new TriggerParameterHintsAction());
|
||||
|
||||
KeybindingsRegistry.registerCommandDesc({
|
||||
id: 'closeParameterHints',
|
||||
handler: handler('closeParameterHints', c => c.cancel()),
|
||||
weight,
|
||||
when: KbExpr.and(EditorKbExpr.TextFocus, Context.Visible),
|
||||
primary: KeyCode.Escape,
|
||||
secondary: [KeyMod.Shift | KeyCode.Escape]
|
||||
});
|
||||
CommonEditorRegistry.registerEditorCommand2(new ParameterHintsCommand(
|
||||
'closeParameterHints',
|
||||
x => x.cancel(),
|
||||
{
|
||||
primary: KeyCode.Escape,
|
||||
secondary: [KeyMod.Shift | KeyCode.Escape]
|
||||
}
|
||||
));
|
||||
|
||||
KeybindingsRegistry.registerCommandDesc({
|
||||
id: 'showPrevParameterHint',
|
||||
handler: handler('showPrevParameterHint', c => c.previous()),
|
||||
weight,
|
||||
when: KbExpr.and(EditorKbExpr.TextFocus, Context.Visible, Context.MultipleSignatures),
|
||||
primary: KeyCode.UpArrow,
|
||||
secondary: [KeyMod.Alt | KeyCode.UpArrow],
|
||||
mac: { primary: KeyCode.UpArrow, secondary: [KeyMod.Alt | KeyCode.UpArrow, KeyMod.WinCtrl | KeyCode.KEY_P] }
|
||||
});
|
||||
|
||||
KeybindingsRegistry.registerCommandDesc({
|
||||
id: 'showNextParameterHint',
|
||||
handler: handler('showNextParameterHint', c => c.next()),
|
||||
weight,
|
||||
when: KbExpr.and(EditorKbExpr.TextFocus, Context.Visible, Context.MultipleSignatures),
|
||||
primary: KeyCode.DownArrow,
|
||||
secondary: [KeyMod.Alt | KeyCode.DownArrow],
|
||||
mac: { primary: KeyCode.DownArrow, secondary: [KeyMod.Alt | KeyCode.DownArrow, KeyMod.WinCtrl | KeyCode.KEY_N] }
|
||||
});
|
||||
CommonEditorRegistry.registerEditorCommand2(new MultipleSignaturesParameterHintsCommand(
|
||||
'showPrevParameterHint',
|
||||
x => x.previous(),
|
||||
{
|
||||
primary: KeyCode.UpArrow,
|
||||
secondary: [KeyMod.Alt | KeyCode.UpArrow],
|
||||
mac: { primary: KeyCode.UpArrow, secondary: [KeyMod.Alt | KeyCode.UpArrow, KeyMod.WinCtrl | KeyCode.KEY_P] }
|
||||
}
|
||||
));
|
||||
CommonEditorRegistry.registerEditorCommand2(new MultipleSignaturesParameterHintsCommand(
|
||||
'showNextParameterHint',
|
||||
x => x.next(),
|
||||
{
|
||||
primary: KeyCode.DownArrow,
|
||||
secondary: [KeyMod.Alt | KeyCode.DownArrow],
|
||||
mac: { primary: KeyCode.DownArrow, secondary: [KeyMod.Alt | KeyCode.DownArrow, KeyMod.WinCtrl | KeyCode.KEY_N] }
|
||||
}
|
||||
));
|
||||
|
|
|
@ -146,9 +146,10 @@ export class QuickFixAction extends EditorAction {
|
|||
var CONTEXT_QUICK_FIX_WIDGET_VISIBLE = new KbCtxKey('quickFixWidgetVisible');
|
||||
|
||||
const QuickFixCommand = EditorCommand.bindToContribution<QuickFixController>(
|
||||
QuickFixController.getQuickFixController,
|
||||
CommonEditorRegistry.commandWeight(80),
|
||||
KbExpr.and(EditorKbExpr.Focus, CONTEXT_QUICK_FIX_WIDGET_VISIBLE)
|
||||
QuickFixController.getQuickFixController, {
|
||||
weight: CommonEditorRegistry.commandWeight(80),
|
||||
kbExpr: KbExpr.and(EditorKbExpr.Focus, CONTEXT_QUICK_FIX_WIDGET_VISIBLE)
|
||||
}
|
||||
);
|
||||
|
||||
// register action
|
||||
|
|
|
@ -10,7 +10,7 @@ import URI from 'vs/base/common/uri';
|
|||
import {TPromise} from 'vs/base/common/winjs.base';
|
||||
import {IEditorService} from 'vs/platform/editor/common/editor';
|
||||
import {optional} from 'vs/platform/instantiation/common/instantiation';
|
||||
import {ICommandHandler} from 'vs/platform/commands/common/commands';
|
||||
import {CommandsRegistry, ICommandHandler} from 'vs/platform/commands/common/commands';
|
||||
import {IKeybindingService, KbExpr} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {KeybindingsRegistry} from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||
import {Position} from 'vs/editor/common/core/position';
|
||||
|
@ -156,20 +156,10 @@ let showReferencesCommand: ICommandHandler = (accessor:ServicesAccessor, resourc
|
|||
CommonEditorRegistry.registerEditorContribution(ReferenceController);
|
||||
CommonEditorRegistry.registerEditorAction(new ReferenceAction());
|
||||
|
||||
KeybindingsRegistry.registerCommandDesc({
|
||||
id: 'editor.action.findReferences',
|
||||
handler: findReferencesCommand,
|
||||
weight: CommonEditorRegistry.commandWeight(50),
|
||||
when: null,
|
||||
primary: undefined
|
||||
});
|
||||
CommandsRegistry.registerCommand('editor.action.findReferences', findReferencesCommand);
|
||||
|
||||
KeybindingsRegistry.registerCommandDesc({
|
||||
id: 'editor.action.showReferences',
|
||||
CommandsRegistry.registerCommand('editor.action.showReferences', {
|
||||
handler: showReferencesCommand,
|
||||
weight: CommonEditorRegistry.commandWeight(50),
|
||||
when: null,
|
||||
primary: undefined,
|
||||
description: {
|
||||
description: 'Show references at a position in a file',
|
||||
args: [
|
||||
|
@ -188,7 +178,7 @@ function closeActiveReferenceSearch(accessor, args) {
|
|||
}
|
||||
}
|
||||
|
||||
KeybindingsRegistry.registerCommandDesc({
|
||||
KeybindingsRegistry.registerCommandAndKeybindingRule({
|
||||
id: 'closeReferenceSearch',
|
||||
weight: CommonEditorRegistry.commandWeight(50),
|
||||
primary: KeyCode.Escape,
|
||||
|
@ -197,7 +187,7 @@ KeybindingsRegistry.registerCommandDesc({
|
|||
handler: closeActiveReferenceSearch
|
||||
});
|
||||
|
||||
KeybindingsRegistry.registerCommandDesc({
|
||||
KeybindingsRegistry.registerCommandAndKeybindingRule({
|
||||
id: 'closeReferenceSearchEditor',
|
||||
weight: CommonEditorRegistry.commandWeight(-101),
|
||||
primary: KeyCode.Escape,
|
||||
|
|
|
@ -190,9 +190,10 @@ export class RenameAction extends EditorAction {
|
|||
EditorBrowserRegistry.registerEditorContribution(RenameController);
|
||||
|
||||
const RenameCommand = EditorCommand.bindToContribution<RenameController>(
|
||||
RenameController.get,
|
||||
CommonEditorRegistry.commandWeight(99),
|
||||
KbExpr.and(EditorKbExpr.Focus, CONTEXT_RENAME_INPUT_VISIBLE)
|
||||
RenameController.get, {
|
||||
weight: CommonEditorRegistry.commandWeight(99),
|
||||
kbExpr: KbExpr.and(EditorKbExpr.Focus, CONTEXT_RENAME_INPUT_VISIBLE)
|
||||
}
|
||||
);
|
||||
|
||||
CommonEditorRegistry.registerEditorAction(new RenameAction());
|
||||
|
|
|
@ -938,9 +938,10 @@ class SnippetController implements ISnippetController {
|
|||
export var CONTEXT_SNIPPET_MODE = new KbCtxKey('inSnippetMode');
|
||||
|
||||
const SnippetCommand = EditorCommand.bindToContribution<ISnippetController>(
|
||||
getSnippetController,
|
||||
CommonEditorRegistry.commandWeight(30),
|
||||
KbExpr.and(EditorKbExpr.TextFocus, CONTEXT_SNIPPET_MODE)
|
||||
getSnippetController, {
|
||||
weight: CommonEditorRegistry.commandWeight(30),
|
||||
kbExpr: KbExpr.and(EditorKbExpr.TextFocus, CONTEXT_SNIPPET_MODE)
|
||||
}
|
||||
);
|
||||
|
||||
CommonEditorRegistry.registerEditorContribution(SnippetController);
|
||||
|
|
|
@ -10,14 +10,12 @@ import { IDisposable, dispose } from 'vs/base/common/lifecycle';
|
|||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { KbExpr } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { ICommonCodeEditor, IEditorContribution, EditorKbExpr } from 'vs/editor/common/editorCommon';
|
||||
import { ServicesAccessor, EditorAction, CommonEditorRegistry } from 'vs/editor/common/editorCommonExtensions';
|
||||
import { ServicesAccessor, EditorAction, EditorCommand, CommonEditorRegistry } from 'vs/editor/common/editorCommonExtensions';
|
||||
import { ISuggestSupport, SuggestRegistry } from 'vs/editor/common/modes';
|
||||
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import { EditorBrowserRegistry } from 'vs/editor/browser/editorBrowserExtensions';
|
||||
import { getSnippetController } from 'vs/editor/contrib/snippet/common/snippet';
|
||||
import { Context as SuggestContext } from 'vs/editor/contrib/suggest/common/suggest';
|
||||
import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||
import { withCodeEditorFromCommandHandler } from 'vs/editor/common/config/config';
|
||||
import { SuggestModel } from '../common/suggestModel';
|
||||
import { SuggestWidget } from './suggestWidget';
|
||||
|
||||
|
@ -204,82 +202,95 @@ CommonEditorRegistry.registerEditorAction(new TriggerSuggestAction());
|
|||
|
||||
const weight = CommonEditorRegistry.commandWeight(90);
|
||||
|
||||
function handler(id: string, fn: (controller: SuggestController) => void) {
|
||||
return accessor => withCodeEditorFromCommandHandler(id, accessor, editor => {
|
||||
fn(SuggestController.getController(editor));
|
||||
});
|
||||
}
|
||||
const SuggestCommand = EditorCommand.bindToContribution(
|
||||
SuggestController.getController, {
|
||||
weight: weight,
|
||||
kbExpr: KbExpr.and(EditorKbExpr.TextFocus, SuggestContext.Visible)
|
||||
}
|
||||
);
|
||||
const MultipleSuggestionsCommand = EditorCommand.bindToContribution(
|
||||
SuggestController.getController, {
|
||||
weight: weight,
|
||||
kbExpr: KbExpr.and(EditorKbExpr.TextFocus, SuggestContext.Visible, SuggestContext.MultipleSuggestions)
|
||||
}
|
||||
);
|
||||
const AcceptSuggestionsOnEnterCommand = EditorCommand.bindToContribution(
|
||||
SuggestController.getController, {
|
||||
weight: weight,
|
||||
kbExpr: KbExpr.and(EditorKbExpr.TextFocus, SuggestContext.Visible, KbExpr.has('config.editor.acceptSuggestionOnEnter'))
|
||||
}
|
||||
);
|
||||
|
||||
KeybindingsRegistry.registerCommandDesc({
|
||||
id: 'acceptSelectedSuggestion',
|
||||
handler: handler('acceptSelectedSuggestion', c => c.acceptSelectedSuggestion()),
|
||||
weight,
|
||||
when: KbExpr.and(EditorKbExpr.TextFocus, SuggestContext.Visible),
|
||||
primary: KeyCode.Tab
|
||||
});
|
||||
CommonEditorRegistry.registerEditorCommand2(new SuggestCommand(
|
||||
'acceptSelectedSuggestion',
|
||||
x => x.acceptSelectedSuggestion(),
|
||||
{
|
||||
primary: KeyCode.Tab
|
||||
}
|
||||
));
|
||||
|
||||
KeybindingsRegistry.registerCommandDesc({
|
||||
id: 'acceptSelectedSuggestionOnEnter',
|
||||
handler: handler('acceptSelectedSuggestionOnEnter', c => c.acceptSelectedSuggestion()),
|
||||
weight,
|
||||
when: KbExpr.and(EditorKbExpr.TextFocus, SuggestContext.Visible, KbExpr.has('config.editor.acceptSuggestionOnEnter')),
|
||||
primary: KeyCode.Enter
|
||||
});
|
||||
CommonEditorRegistry.registerEditorCommand2(new AcceptSuggestionsOnEnterCommand(
|
||||
'acceptSelectedSuggestionOnEnter',
|
||||
x => x.acceptSelectedSuggestion(),
|
||||
{
|
||||
primary: KeyCode.Enter
|
||||
}
|
||||
));
|
||||
|
||||
KeybindingsRegistry.registerCommandDesc({
|
||||
id: 'hideSuggestWidget',
|
||||
handler: handler('hideSuggestWidget', c => c.cancelSuggestWidget()),
|
||||
weight,
|
||||
when: KbExpr.and(EditorKbExpr.TextFocus, SuggestContext.Visible),
|
||||
primary: KeyCode.Escape,
|
||||
secondary: [KeyMod.Shift | KeyCode.Escape]
|
||||
});
|
||||
CommonEditorRegistry.registerEditorCommand2(new SuggestCommand(
|
||||
'hideSuggestWidget',
|
||||
x => x.cancelSuggestWidget(),
|
||||
{
|
||||
primary: KeyCode.Escape,
|
||||
secondary: [KeyMod.Shift | KeyCode.Escape]
|
||||
}
|
||||
));
|
||||
|
||||
KeybindingsRegistry.registerCommandDesc({
|
||||
id: 'selectNextSuggestion',
|
||||
handler: handler('selectNextSuggestion', c => c.selectNextSuggestion()),
|
||||
weight,
|
||||
when: KbExpr.and(EditorKbExpr.TextFocus, SuggestContext.Visible, SuggestContext.MultipleSuggestions),
|
||||
primary: KeyCode.DownArrow,
|
||||
secondary: [KeyMod.Alt | KeyCode.DownArrow],
|
||||
mac: { primary: KeyCode.DownArrow, secondary: [KeyMod.Alt | KeyCode.DownArrow, KeyMod.WinCtrl | KeyCode.KEY_N] }
|
||||
});
|
||||
CommonEditorRegistry.registerEditorCommand2(new MultipleSuggestionsCommand(
|
||||
'selectNextSuggestion',
|
||||
c => c.selectNextSuggestion(),
|
||||
{
|
||||
primary: KeyCode.DownArrow,
|
||||
secondary: [KeyMod.Alt | KeyCode.DownArrow],
|
||||
mac: { primary: KeyCode.DownArrow, secondary: [KeyMod.Alt | KeyCode.DownArrow, KeyMod.WinCtrl | KeyCode.KEY_N] }
|
||||
}
|
||||
));
|
||||
|
||||
KeybindingsRegistry.registerCommandDesc({
|
||||
id: 'selectNextPageSuggestion',
|
||||
handler: handler('selectNextPageSuggestion', c => c.selectNextPageSuggestion()),
|
||||
weight,
|
||||
when: KbExpr.and(EditorKbExpr.TextFocus, SuggestContext.Visible, SuggestContext.MultipleSuggestions),
|
||||
primary: KeyCode.PageDown,
|
||||
secondary: [KeyMod.Alt | KeyCode.PageDown]
|
||||
});
|
||||
CommonEditorRegistry.registerEditorCommand2(new MultipleSuggestionsCommand(
|
||||
'selectNextPageSuggestion',
|
||||
c => c.selectNextPageSuggestion(),
|
||||
{
|
||||
primary: KeyCode.PageDown,
|
||||
secondary: [KeyMod.Alt | KeyCode.PageDown]
|
||||
}
|
||||
));
|
||||
|
||||
KeybindingsRegistry.registerCommandDesc({
|
||||
id: 'selectPrevSuggestion',
|
||||
handler: handler('selectPrevSuggestion', c => c.selectPrevSuggestion()),
|
||||
weight,
|
||||
when: KbExpr.and(EditorKbExpr.TextFocus, SuggestContext.Visible, SuggestContext.MultipleSuggestions),
|
||||
primary: KeyCode.UpArrow,
|
||||
secondary: [KeyMod.Alt | KeyCode.UpArrow],
|
||||
mac: { primary: KeyCode.UpArrow, secondary: [KeyMod.Alt | KeyCode.UpArrow, KeyMod.WinCtrl | KeyCode.KEY_P] }
|
||||
});
|
||||
CommonEditorRegistry.registerEditorCommand2(new MultipleSuggestionsCommand(
|
||||
'selectPrevSuggestion',
|
||||
c => c.selectPrevSuggestion(),
|
||||
{
|
||||
primary: KeyCode.UpArrow,
|
||||
secondary: [KeyMod.Alt | KeyCode.UpArrow],
|
||||
mac: { primary: KeyCode.UpArrow, secondary: [KeyMod.Alt | KeyCode.UpArrow, KeyMod.WinCtrl | KeyCode.KEY_P] }
|
||||
}
|
||||
));
|
||||
|
||||
KeybindingsRegistry.registerCommandDesc({
|
||||
id: 'selectPrevPageSuggestion',
|
||||
handler: handler('selectPrevPageSuggestion', c => c.selectPrevPageSuggestion()),
|
||||
weight,
|
||||
when: KbExpr.and(EditorKbExpr.TextFocus, SuggestContext.Visible, SuggestContext.MultipleSuggestions),
|
||||
primary: KeyCode.PageUp,
|
||||
secondary: [KeyMod.Alt | KeyCode.PageUp]
|
||||
});
|
||||
CommonEditorRegistry.registerEditorCommand2(new MultipleSuggestionsCommand(
|
||||
'selectPrevPageSuggestion',
|
||||
c => c.selectPrevPageSuggestion(),
|
||||
{
|
||||
primary: KeyCode.PageUp,
|
||||
secondary: [KeyMod.Alt | KeyCode.PageUp]
|
||||
}
|
||||
));
|
||||
|
||||
KeybindingsRegistry.registerCommandDesc({
|
||||
id: 'toggleSuggestionDetails',
|
||||
handler: handler('toggleSuggestionDetails', c => c.toggleSuggestionDetails()),
|
||||
weight,
|
||||
when: KbExpr.and(EditorKbExpr.TextFocus, SuggestContext.Visible),
|
||||
primary: KeyMod.CtrlCmd | KeyCode.Space,
|
||||
mac: { primary: KeyMod.WinCtrl | KeyCode.Space }
|
||||
});
|
||||
CommonEditorRegistry.registerEditorCommand2(new SuggestCommand(
|
||||
'toggleSuggestionDetails',
|
||||
x => x.toggleSuggestionDetails(),
|
||||
{
|
||||
primary: KeyMod.CtrlCmd | KeyCode.Space,
|
||||
mac: { primary: KeyMod.WinCtrl | KeyCode.Space }
|
||||
}
|
||||
));
|
||||
|
||||
EditorBrowserRegistry.registerEditorContribution(SuggestController);
|
||||
|
|
|
@ -76,14 +76,15 @@ class TabCompletionController implements editorCommon.IEditorContribution {
|
|||
CommonEditorRegistry.registerEditorContribution(TabCompletionController);
|
||||
|
||||
const TabCompletionCommand = EditorCommand.bindToContribution<TabCompletionController>(
|
||||
(editor) => <TabCompletionController>editor.getContribution(TabCompletionController.Id),
|
||||
KeybindingsRegistry.WEIGHT.editorContrib(),
|
||||
KbExpr.and(
|
||||
TabCompletionController.ContextKey,
|
||||
EditorKbExpr.TextFocus,
|
||||
EditorKbExpr.TabDoesNotMoveFocus,
|
||||
KbExpr.has('config.editor.tabCompletion')
|
||||
)
|
||||
(editor) => <TabCompletionController>editor.getContribution(TabCompletionController.Id), {
|
||||
weight: KeybindingsRegistry.WEIGHT.editorContrib(),
|
||||
kbExpr: KbExpr.and(
|
||||
TabCompletionController.ContextKey,
|
||||
EditorKbExpr.TextFocus,
|
||||
EditorKbExpr.TabDoesNotMoveFocus,
|
||||
KbExpr.has('config.editor.tabCompletion')
|
||||
)
|
||||
}
|
||||
);
|
||||
|
||||
CommonEditorRegistry.registerEditorCommand2(new TabCompletionCommand(
|
||||
|
|
|
@ -33,7 +33,7 @@ export class ToggleTabFocusModeAction extends EditorAction {
|
|||
// register actions
|
||||
CommonEditorRegistry.registerEditorAction(new ToggleTabFocusModeAction());
|
||||
|
||||
KeybindingsRegistry.registerCommandRule({
|
||||
KeybindingsRegistry.registerKeybindingRule({
|
||||
id: ToggleTabFocusModeAction.ID,
|
||||
weight: KeybindingsRegistry.WEIGHT.editorContrib(),
|
||||
when: null,
|
||||
|
|
|
@ -10,20 +10,20 @@ import {IKeybindingItem, IKeybindings, KbExpr} from 'vs/platform/keybinding/comm
|
|||
import {CommandsRegistry, ICommandHandler, ICommandHandlerDescription} from 'vs/platform/commands/common/commands';
|
||||
import {Registry} from 'vs/platform/platform';
|
||||
|
||||
export interface ICommandRule extends IKeybindings {
|
||||
export interface IKeybindingRule extends IKeybindings {
|
||||
id: string;
|
||||
weight: number;
|
||||
when: KbExpr;
|
||||
}
|
||||
|
||||
export interface ICommandDescriptor extends ICommandRule {
|
||||
export interface ICommandAndKeybindingRule extends IKeybindingRule {
|
||||
handler: ICommandHandler;
|
||||
description?: ICommandHandlerDescription;
|
||||
}
|
||||
|
||||
export interface IKeybindingsRegistry {
|
||||
registerCommandRule(rule: ICommandRule);
|
||||
registerCommandDesc(desc: ICommandDescriptor): void;
|
||||
registerKeybindingRule(rule: IKeybindingRule);
|
||||
registerCommandAndKeybindingRule(desc: ICommandAndKeybindingRule): void;
|
||||
getDefaultKeybindings(): IKeybindingItem[];
|
||||
|
||||
WEIGHT: {
|
||||
|
@ -82,7 +82,7 @@ class KeybindingsRegistryImpl implements IKeybindingsRegistry {
|
|||
return kb;
|
||||
}
|
||||
|
||||
public registerCommandRule(rule: ICommandRule): void {
|
||||
public registerKeybindingRule(rule: IKeybindingRule): void {
|
||||
let actualKb = KeybindingsRegistryImpl.bindToCurrentPlatform(rule);
|
||||
|
||||
// here
|
||||
|
@ -96,8 +96,8 @@ class KeybindingsRegistryImpl implements IKeybindingsRegistry {
|
|||
}
|
||||
}
|
||||
|
||||
public registerCommandDesc(desc: ICommandDescriptor): void {
|
||||
this.registerCommandRule(desc);
|
||||
public registerCommandAndKeybindingRule(desc: ICommandAndKeybindingRule): void {
|
||||
this.registerKeybindingRule(desc);
|
||||
CommandsRegistry.registerCommand(desc.id, desc);
|
||||
}
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ registry.registerWorkbenchAction(new SyncActionDescriptor(ChangeEOLAction, Chang
|
|||
registry.registerWorkbenchAction(new SyncActionDescriptor(ChangeEncodingAction, ChangeEncodingAction.ID, ChangeEncodingAction.LABEL), 'Change File Encoding');
|
||||
|
||||
// Register keybinding for "Next Change" & "Previous Change" in visible diff editor
|
||||
KeybindingsRegistry.registerCommandDesc({
|
||||
KeybindingsRegistry.registerCommandAndKeybindingRule({
|
||||
id: 'workbench.action.compareEditor.nextChange',
|
||||
weight: KeybindingsRegistry.WEIGHT.workbenchContrib(),
|
||||
when: KbExpr.has('textCompareEditorVisible'),
|
||||
|
@ -99,7 +99,7 @@ KeybindingsRegistry.registerCommandDesc({
|
|||
handler: accessor => navigateInDiffEditor(accessor, true)
|
||||
});
|
||||
|
||||
KeybindingsRegistry.registerCommandDesc({
|
||||
KeybindingsRegistry.registerCommandAndKeybindingRule({
|
||||
id: 'workbench.action.compareEditor.previousChange',
|
||||
weight: KeybindingsRegistry.WEIGHT.workbenchContrib(),
|
||||
when: KbExpr.has('textCompareEditorVisible'),
|
||||
|
@ -116,7 +116,7 @@ function navigateInDiffEditor(accessor: ServicesAccessor, next: boolean): void {
|
|||
}
|
||||
}
|
||||
|
||||
KeybindingsRegistry.registerCommandDesc({
|
||||
KeybindingsRegistry.registerCommandAndKeybindingRule({
|
||||
id: '_workbench.printStacksModel',
|
||||
weight: KeybindingsRegistry.WEIGHT.workbenchContrib(0),
|
||||
handler(accessor: ServicesAccessor) {
|
||||
|
@ -126,7 +126,7 @@ KeybindingsRegistry.registerCommandDesc({
|
|||
primary: undefined
|
||||
});
|
||||
|
||||
KeybindingsRegistry.registerCommandDesc({
|
||||
KeybindingsRegistry.registerCommandAndKeybindingRule({
|
||||
id: '_workbench.validateStacksModel',
|
||||
weight: KeybindingsRegistry.WEIGHT.workbenchContrib(0),
|
||||
handler(accessor: ServicesAccessor) {
|
||||
|
@ -338,7 +338,7 @@ for (let i = 0; i < 9; i++) {
|
|||
const editorIndex = i;
|
||||
const visibleIndex = i + 1;
|
||||
|
||||
KeybindingsRegistry.registerCommandDesc({
|
||||
KeybindingsRegistry.registerCommandAndKeybindingRule({
|
||||
id: 'workbench.action.openEditorAtIndex' + visibleIndex,
|
||||
weight: KeybindingsRegistry.WEIGHT.workbenchContrib(),
|
||||
when: void 0,
|
||||
|
|
|
@ -42,7 +42,7 @@ let isActiveEditorMoveArg= function(arg): boolean {
|
|||
|
||||
|
||||
function _registerActiveEditorMoveCommand() {
|
||||
KeybindingsRegistry.registerCommandDesc({
|
||||
KeybindingsRegistry.registerCommandAndKeybindingRule({
|
||||
id: EditorCommands.MoveActiveEditor,
|
||||
weight: KeybindingsRegistry.WEIGHT.workbenchContrib(),
|
||||
when: EditorKbExpr.TextFocus,
|
||||
|
|
|
@ -8,7 +8,7 @@ import {TPromise} from 'vs/base/common/winjs.base';
|
|||
import collections = require('vs/base/common/collections');
|
||||
import {Registry} from 'vs/platform/platform';
|
||||
import {IAction} from 'vs/base/common/actions';
|
||||
import {KeybindingsRegistry, ICommandDescriptor} from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||
import {KeybindingsRegistry, ICommandAndKeybindingRule} from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||
import {IPartService} from 'vs/workbench/services/part/common/partService';
|
||||
import {ICommandHandler} from 'vs/platform/commands/common/commands';
|
||||
import {SyncActionDescriptor} from 'vs/platform/actions/common/actions';
|
||||
|
@ -129,7 +129,7 @@ function registerWorkbenchCommandFromAction(descriptor: SyncActionDescriptor): v
|
|||
let weight = (typeof descriptor.keybindingWeight === 'undefined' ? KeybindingsRegistry.WEIGHT.workbenchContrib() : descriptor.keybindingWeight);
|
||||
let keybindings = descriptor.keybindings;
|
||||
|
||||
let desc: ICommandDescriptor = {
|
||||
let desc: ICommandAndKeybindingRule = {
|
||||
id: descriptor.id,
|
||||
handler: createCommandHandler(descriptor),
|
||||
weight: weight,
|
||||
|
@ -141,7 +141,7 @@ function registerWorkbenchCommandFromAction(descriptor: SyncActionDescriptor): v
|
|||
linux: keybindings && keybindings.linux
|
||||
};
|
||||
|
||||
KeybindingsRegistry.registerCommandDesc(desc);
|
||||
KeybindingsRegistry.registerCommandAndKeybindingRule(desc);
|
||||
}
|
||||
|
||||
export function createCommandHandler(descriptor: SyncActionDescriptor): ICommandHandler {
|
||||
|
|
|
@ -42,7 +42,7 @@ if (platform.isWindows || platform.isLinux) {
|
|||
}
|
||||
|
||||
// close the window when the last editor is closed by reusing the same keybinding
|
||||
KeybindingsRegistry.registerCommandDesc({
|
||||
KeybindingsRegistry.registerCommandAndKeybindingRule({
|
||||
id: 'workbench.action.closeWindow',
|
||||
weight: KeybindingsRegistry.WEIGHT.workbenchContrib(),
|
||||
when: KbExpr.not('editorIsOpen'),
|
||||
|
|
|
@ -113,7 +113,7 @@ registry.registerWorkbenchAction(new SyncActionDescriptor(RemoveAllBreakpointsAc
|
|||
registry.registerWorkbenchAction(new SyncActionDescriptor(EnableAllBreakpointsAction, EnableAllBreakpointsAction.ID, EnableAllBreakpointsAction.LABEL), 'Debug: Enable All Breakpoints', debugCategory);
|
||||
registry.registerWorkbenchAction(new SyncActionDescriptor(DisableAllBreakpointsAction, DisableAllBreakpointsAction.ID, DisableAllBreakpointsAction.LABEL), 'Debug: Disable All Breakpoints', debugCategory);
|
||||
|
||||
KeybindingsRegistry.registerCommandDesc({
|
||||
KeybindingsRegistry.registerCommandAndKeybindingRule({
|
||||
id: '_workbench.startDebug',
|
||||
weight: KeybindingsRegistry.WEIGHT.workbenchContrib(0),
|
||||
handler(accessor: ServicesAccessor, configuration: any) {
|
||||
|
|
|
@ -104,7 +104,7 @@ function registerAction(desc: IActionDescriptor) {
|
|||
// 4) keybindings
|
||||
if (keybinding) {
|
||||
let {when, weight, keys} = keybinding;
|
||||
KeybindingsRegistry.registerCommandRule({
|
||||
KeybindingsRegistry.registerKeybindingRule({
|
||||
id,
|
||||
when,
|
||||
weight,
|
||||
|
|
|
@ -33,7 +33,7 @@ import { registerContributions as searchWidgetContributions } from 'vs/workbench
|
|||
replaceContributions();
|
||||
searchWidgetContributions();
|
||||
|
||||
KeybindingsRegistry.registerCommandDesc({
|
||||
KeybindingsRegistry.registerCommandAndKeybindingRule({
|
||||
id: 'workbench.action.search.toggleQueryDetails',
|
||||
weight: KeybindingsRegistry.WEIGHT.workbenchContrib(),
|
||||
when: KbExpr.has('searchViewletVisible'),
|
||||
|
|
|
@ -331,7 +331,7 @@ export class SearchWidget extends Widget {
|
|||
}
|
||||
|
||||
export function registerContributions() {
|
||||
KeybindingsRegistry.registerCommandDesc({id: ReplaceAllAction.ID,
|
||||
KeybindingsRegistry.registerCommandAndKeybindingRule({id: ReplaceAllAction.ID,
|
||||
weight: KeybindingsRegistry.WEIGHT.workbenchContrib(),
|
||||
when: KbExpr.and(KbExpr.has('searchViewletVisible'), SearchWidget.REPLACE_ACTIVE_CONTEXT_KEY, CONTEXT_FIND_WIDGET_NOT_VISIBLE),
|
||||
primary: KeyMod.Alt | KeyMod.CtrlCmd | KeyCode.Enter,
|
||||
|
|
|
@ -17,7 +17,7 @@ import {IStatusbarService} from 'vs/platform/statusbar/common/statusbar';
|
|||
import {IOSupport} from 'vs/platform/keybinding/common/keybindingResolver';
|
||||
import {ICommandService} from 'vs/platform/commands/common/commands';
|
||||
import {IKeybindingItem, IUserFriendlyKeybinding} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {ICommandRule, KeybindingsRegistry} from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||
import {IKeybindingRule, KeybindingsRegistry} from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||
import {Registry} from 'vs/platform/platform';
|
||||
import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry';
|
||||
import {IConfigurationService} from 'vs/platform/configuration/common/configuration';
|
||||
|
@ -237,7 +237,7 @@ export class WorkbenchKeybindingService extends KeybindingService {
|
|||
if (isValidContributedKeyBinding(keybindings, rejects)) {
|
||||
let rule = this._asCommandRule(isBuiltin, idx++, keybindings);
|
||||
if (rule) {
|
||||
KeybindingsRegistry.registerCommandRule(rule);
|
||||
KeybindingsRegistry.registerKeybindingRule(rule);
|
||||
commandAdded = true;
|
||||
}
|
||||
}
|
||||
|
@ -254,7 +254,7 @@ export class WorkbenchKeybindingService extends KeybindingService {
|
|||
return commandAdded;
|
||||
}
|
||||
|
||||
private _asCommandRule(isBuiltin: boolean, idx: number, binding: ContributedKeyBinding): ICommandRule {
|
||||
private _asCommandRule(isBuiltin: boolean, idx: number, binding: ContributedKeyBinding): IKeybindingRule {
|
||||
|
||||
let {command, when, key, mac, linux, win} = binding;
|
||||
|
||||
|
|
Loading…
Reference in a new issue