Use options interface for editor actions and editor commands ctor

This commit is contained in:
Alex Dima 2016-08-08 14:53:24 +02:00
parent 9f53cc4f67
commit 016c161edf
42 changed files with 1871 additions and 1819 deletions

View file

@ -18,32 +18,49 @@ import H = editorCommon.Handler;
import D = editorCommon.CommandDescription;
import EditorContextKeys = editorCommon.EditorContextKeys;
export interface IKeybindingsOptions {
const CORE_WEIGHT = KeybindingsRegistry.WEIGHT.editorCore();
export interface ICommandKeybindingsOptions extends IKeybindings {
kbExpr?: KbExpr;
weight?: number;
}
export interface ICommandKeybindingsOptions extends IKeybindings, IKeybindingsOptions {
export interface ICommandOptions {
id: string;
precondition: KbExpr;
kbOpts?: ICommandKeybindingsOptions;
}
export abstract class Command {
public id: string;
public kbOpts: ICommandKeybindingsOptions;
public precondition: KbExpr;
private kbOpts: ICommandKeybindingsOptions;
constructor(id:string) {
this.id = id;
this.kbOpts = null;
constructor(opts:ICommandOptions) {
this.id = opts.id;
this.precondition = opts.precondition;
this.kbOpts = opts.kbOpts;
}
public abstract runCommand(accessor:ServicesAccessor, args: any): void | TPromise<void>;
public toCommandAndKeybindingRule(defaultWeight:number): ICommandAndKeybindingRule {
const kbOpts = this.kbOpts || { primary: 0 };
let kbWhen = kbOpts.kbExpr;
if (this.precondition) {
if (kbWhen) {
kbWhen = KbExpr.and(kbWhen, this.precondition);
} else {
kbWhen = this.precondition;
}
}
return {
id: this.id,
handler: (accessor, args) => this.runCommand(accessor, args),
weight: kbOpts.weight || defaultWeight,
when: kbOpts.kbExpr,
when: kbWhen,
primary: kbOpts.primary,
secondary: kbOpts.secondary,
win: kbOpts.win,
@ -54,33 +71,24 @@ export abstract class Command {
}
export interface EditorControllerCommand<T extends editorCommon.IEditorContribution> {
new(id:string, callback:(controller:T)=>void, keybindings:ICommandKeybindingsOptions): EditorCommand;
new(opts:IContributionCommandOptions<T>): EditorCommand;
}
export interface IContributionCommandOptions<T> extends ICommandOptions {
handler: (controller:T)=>void;
}
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;
public static bindToContribution<T extends editorCommon.IEditorContribution>(controllerGetter:(editor:editorCommon.ICommonCodeEditor) => T): EditorControllerCommand<T> {
return class EditorControllerCommandImpl extends EditorCommand {
private _callback:(controller:T)=>void;
constructor(id:string, callback:(controller:T)=>void, keybindings:ICommandKeybindingsOptions) {
super(id);
constructor(opts:IContributionCommandOptions<T>) {
super(opts);
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,
};
this._callback = opts.handler;
}
protected runEditorCommand(accessor:ServicesAccessor, editor: editorCommon.ICommonCodeEditor, args: any): void {
@ -89,8 +97,8 @@ export abstract class EditorCommand extends Command {
};
}
constructor(id:string) {
super(id);
constructor(opts:ICommandOptions) {
super(opts);
}
public runCommand(accessor:ServicesAccessor, args: any): void | TPromise<void> {
@ -110,26 +118,6 @@ export abstract class EditorCommand extends Command {
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) {
@ -170,14 +158,23 @@ function triggerEditorHandler(handlerId: string, accessor: ServicesAccessor, arg
});
}
function registerCoreCommand(handlerId: string, kb: IKeybindings, weight?: number, when?: KbExpr): void {
let command = new CoreCommand(
handlerId,
weight,
when ? when : EditorContextKeys.TextFocus,
kb
);
KeybindingsRegistry.registerCommandAndKeybindingRule(command.toCommandAndKeybindingRule(KeybindingsRegistry.WEIGHT.editorCore()));
class CoreCommand extends Command {
public runCommand(accessor:ServicesAccessor, args: any): void {
triggerEditorHandler(this.id, accessor, args);
}
}
class UnboundCoreCommand extends CoreCommand {
constructor(handlerId:string, precondition: KbExpr = null) {
super({
id: handlerId,
precondition: precondition
});
}
}
function registerCommand(command:Command) {
KeybindingsRegistry.registerCommandAndKeybindingRule(command.toCommandAndKeybindingRule(CORE_WEIGHT));
}
function registerCoreAPICommand(handlerId: string, description: ICommandHandlerDescription): void {
@ -203,21 +200,36 @@ registerCoreDispatchCommand(H.Cut);
registerOverwritableCommand(H.CompositionStart, () => {});
registerOverwritableCommand(H.CompositionEnd, () => {});
function getMacWordNavigationKB(shift:boolean, key:KeyCode): number {
// For macs, word navigation is based on the alt modifier
if (shift) {
return KeyMod.Shift | KeyMod.Alt | key;
} else {
return KeyMod.Alt | key;
class WordCommand extends CoreCommand {
public static getMacWordNavigationKB(shift:boolean, key:KeyCode): number {
// For macs, word navigation is based on the alt modifier
if (shift) {
return KeyMod.Shift | KeyMod.Alt | key;
} else {
return KeyMod.Alt | key;
}
}
}
function getWordNavigationKB(shift:boolean, key:KeyCode): number {
// Normally word navigation is based on the ctrl modifier
if (shift) {
return KeyMod.CtrlCmd | KeyMod.Shift | key;
} else {
return KeyMod.CtrlCmd | key;
public static getWordNavigationKB(shift:boolean, key:KeyCode): number {
// Normally word navigation is based on the ctrl modifier
if (shift) {
return KeyMod.CtrlCmd | KeyMod.Shift | key;
} else {
return KeyMod.CtrlCmd | key;
}
}
constructor(handlerId: string, shift:boolean, key:KeyCode, precondition: KbExpr = null) {
super({
id: handlerId,
precondition: precondition,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.TextFocus,
primary: WordCommand.getWordNavigationKB(shift, key),
mac: { primary: WordCommand.getMacWordNavigationKB(shift, key) }
}
});
}
}
@ -263,260 +275,515 @@ function getWordNavigationKB(shift:boolean, key:KeyCode): number {
// Register cursor commands
registerCoreAPICommand(H.CursorMove, D.CursorMove);
registerCoreCommand(H.CursorLeft, {
primary: KeyCode.LeftArrow,
mac: { primary: KeyCode.LeftArrow, secondary: [KeyMod.WinCtrl | KeyCode.KEY_B] }
});
registerCoreCommand(H.CursorLeftSelect, {
primary: KeyMod.Shift | KeyCode.LeftArrow
});
registerCoreCommand(H.CursorRight, {
primary: KeyCode.RightArrow,
mac: { primary: KeyCode.RightArrow, secondary: [KeyMod.WinCtrl | KeyCode.KEY_F] }
});
registerCoreCommand(H.CursorRightSelect, {
primary: KeyMod.Shift | KeyCode.RightArrow
});
registerCoreCommand(H.CursorUp, {
primary: KeyCode.UpArrow,
mac: { primary: KeyCode.UpArrow, secondary: [KeyMod.WinCtrl | KeyCode.KEY_P] }
});
registerCoreCommand(H.CursorUpSelect, {
primary: KeyMod.Shift | KeyCode.UpArrow,
secondary: [getWordNavigationKB(true, KeyCode.UpArrow)],
mac: { primary: KeyMod.Shift | KeyCode.UpArrow },
linux: { primary: KeyMod.Shift | KeyCode.UpArrow }
});
registerCoreCommand(H.CursorDown, {
primary: KeyCode.DownArrow,
mac: { primary: KeyCode.DownArrow, secondary: [KeyMod.WinCtrl | KeyCode.KEY_N] }
});
registerCoreCommand(H.CursorDownSelect, {
primary: KeyMod.Shift | KeyCode.DownArrow,
secondary: [getWordNavigationKB(true, KeyCode.DownArrow)],
mac: { primary: KeyMod.Shift | KeyCode.DownArrow },
linux: { primary: KeyMod.Shift | KeyCode.DownArrow }
});
registerCommand(new CoreCommand({
id: H.CursorLeft,
precondition: null,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.TextFocus,
primary: KeyCode.LeftArrow,
mac: { primary: KeyCode.LeftArrow, secondary: [KeyMod.WinCtrl | KeyCode.KEY_B] }
}
}));
registerCommand(new CoreCommand({
id: H.CursorLeftSelect,
precondition: null,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.Shift | KeyCode.LeftArrow
}
}));
registerCommand(new CoreCommand({
id: H.CursorRight,
precondition: null,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.TextFocus,
primary: KeyCode.RightArrow,
mac: { primary: KeyCode.RightArrow, secondary: [KeyMod.WinCtrl | KeyCode.KEY_F] }
}
}));
registerCommand(new CoreCommand({
id: H.CursorRightSelect,
precondition: null,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.Shift | KeyCode.RightArrow
}
}));
registerCommand(new CoreCommand({
id: H.CursorUp,
precondition: null,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.TextFocus,
primary: KeyCode.UpArrow,
mac: { primary: KeyCode.UpArrow, secondary: [KeyMod.WinCtrl | KeyCode.KEY_P] }
}
}));
registerCommand(new CoreCommand({
id: H.CursorUpSelect,
precondition: null,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.Shift | KeyCode.UpArrow,
secondary: [WordCommand.getWordNavigationKB(true, KeyCode.UpArrow)],
mac: { primary: KeyMod.Shift | KeyCode.UpArrow },
linux: { primary: KeyMod.Shift | KeyCode.UpArrow }
}
}));
registerCommand(new CoreCommand({
id: H.CursorDown,
precondition: null,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.TextFocus,
primary: KeyCode.DownArrow,
mac: { primary: KeyCode.DownArrow, secondary: [KeyMod.WinCtrl | KeyCode.KEY_N] }
}
}));
registerCommand(new CoreCommand({
id: H.CursorDownSelect,
precondition: null,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.Shift | KeyCode.DownArrow,
secondary: [WordCommand.getWordNavigationKB(true, KeyCode.DownArrow)],
mac: { primary: KeyMod.Shift | KeyCode.DownArrow },
linux: { primary: KeyMod.Shift | KeyCode.DownArrow }
}
}));
registerCoreCommand(H.CursorPageUp, {
primary: KeyCode.PageUp
});
registerCoreCommand(H.CursorPageUpSelect, {
primary: KeyMod.Shift | KeyCode.PageUp
});
registerCoreCommand(H.CursorPageDown, {
primary: KeyCode.PageDown
});
registerCoreCommand(H.CursorPageDownSelect, {
primary: KeyMod.Shift | KeyCode.PageDown
});
registerCoreCommand(H.CursorHome, {
primary: KeyCode.Home,
mac: { primary: KeyCode.Home, secondary: [KeyMod.CtrlCmd | KeyCode.LeftArrow, KeyMod.WinCtrl | KeyCode.KEY_A] }
});
registerCoreCommand(H.CursorHomeSelect, {
primary: KeyMod.Shift | KeyCode.Home,
mac: { primary: KeyMod.Shift | KeyCode.Home, secondary: [KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.LeftArrow] }
});
registerCoreCommand(H.CursorEnd, {
primary: KeyCode.End,
mac: { primary: KeyCode.End, secondary: [KeyMod.CtrlCmd | KeyCode.RightArrow, KeyMod.WinCtrl | KeyCode.KEY_E] }
});
registerCoreCommand(H.CursorEndSelect, {
primary: KeyMod.Shift | KeyCode.End,
mac: { primary: KeyMod.Shift | KeyCode.End, secondary: [KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.RightArrow] }
});
registerCoreCommand(H.ExpandLineSelection, {
primary: KeyMod.CtrlCmd | KeyCode.KEY_I
});
registerCommand(new CoreCommand({
id: H.CursorPageUp,
precondition: null,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.TextFocus,
primary: KeyCode.PageUp
}
}));
registerCommand(new CoreCommand({
id: H.CursorPageUpSelect,
precondition: null,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.Shift | KeyCode.PageUp
}
}));
registerCommand(new CoreCommand({
id: H.CursorPageDown,
precondition: null,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.TextFocus,
primary: KeyCode.PageDown
}
}));
registerCommand(new CoreCommand({
id: H.CursorPageDownSelect,
precondition: null,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.Shift | KeyCode.PageDown
}
}));
registerCommand(new CoreCommand({
id: H.CursorHome,
precondition: null,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.TextFocus,
primary: KeyCode.Home,
mac: { primary: KeyCode.Home, secondary: [KeyMod.CtrlCmd | KeyCode.LeftArrow, KeyMod.WinCtrl | KeyCode.KEY_A] }
}
}));
registerCommand(new CoreCommand({
id: H.CursorHomeSelect,
precondition: null,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.Shift | KeyCode.Home,
mac: { primary: KeyMod.Shift | KeyCode.Home, secondary: [KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.LeftArrow] }
}
}));
registerCommand(new CoreCommand({
id: H.CursorEnd,
precondition: null,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.TextFocus,
primary: KeyCode.End,
mac: { primary: KeyCode.End, secondary: [KeyMod.CtrlCmd | KeyCode.RightArrow, KeyMod.WinCtrl | KeyCode.KEY_E] }
}
}));
registerCommand(new CoreCommand({
id: H.CursorEndSelect,
precondition: null,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.Shift | KeyCode.End,
mac: { primary: KeyMod.Shift | KeyCode.End, secondary: [KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.RightArrow] }
}
}));
registerCommand(new CoreCommand({
id: H.ExpandLineSelection,
precondition: null,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.CtrlCmd | KeyCode.KEY_I
}
}));
registerCoreAPICommand(H.EditorScroll, D.EditorScroll);
registerCoreCommand(H.ScrollLineUp, {
primary: KeyMod.CtrlCmd | KeyCode.UpArrow,
mac: { primary: KeyMod.WinCtrl | KeyCode.PageUp}
});
registerCoreCommand(H.ScrollLineDown, {
primary: KeyMod.CtrlCmd | KeyCode.DownArrow,
mac: { primary: KeyMod.WinCtrl | KeyCode.PageDown}
});
registerCommand(new CoreCommand({
id: H.ScrollLineUp,
precondition: null,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.CtrlCmd | KeyCode.UpArrow,
mac: { primary: KeyMod.WinCtrl | KeyCode.PageUp}
}
}));
registerCommand(new CoreCommand({
id: H.ScrollLineDown,
precondition: null,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.CtrlCmd | KeyCode.DownArrow,
mac: { primary: KeyMod.WinCtrl | KeyCode.PageDown}
}
}));
registerCoreCommand(H.ScrollPageUp, {
primary: KeyMod.CtrlCmd | KeyCode.PageUp,
win: { primary: KeyMod.Alt | KeyCode.PageUp },
linux: { primary: KeyMod.Alt | KeyCode.PageUp }
});
registerCoreCommand(H.ScrollPageDown, {
primary: KeyMod.CtrlCmd | KeyCode.PageDown,
win: { primary: KeyMod.Alt | KeyCode.PageDown },
linux: { primary: KeyMod.Alt | KeyCode.PageDown }
});
registerCommand(new CoreCommand({
id: H.ScrollPageUp,
precondition: null,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.CtrlCmd | KeyCode.PageUp,
win: { primary: KeyMod.Alt | KeyCode.PageUp },
linux: { primary: KeyMod.Alt | KeyCode.PageUp }
}
}));
registerCommand(new CoreCommand({
id: H.ScrollPageDown,
precondition: null,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.CtrlCmd | KeyCode.PageDown,
win: { primary: KeyMod.Alt | KeyCode.PageDown },
linux: { primary: KeyMod.Alt | KeyCode.PageDown }
}
}));
registerCoreCommand(H.CursorColumnSelectLeft, {
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyMod.Alt | KeyCode.LeftArrow,
linux: { primary: 0 }
});
registerCoreCommand(H.CursorColumnSelectRight, {
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyMod.Alt | KeyCode.RightArrow,
linux: { primary: 0 }
});
registerCoreCommand(H.CursorColumnSelectUp, {
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyMod.Alt | KeyCode.UpArrow,
linux: { primary: 0 }
});
registerCoreCommand(H.CursorColumnSelectPageUp, {
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyMod.Alt | KeyCode.PageUp,
linux: { primary: 0 }
});
registerCoreCommand(H.CursorColumnSelectDown, {
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyMod.Alt | KeyCode.DownArrow,
linux: { primary: 0 }
});
registerCoreCommand(H.CursorColumnSelectPageDown, {
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyMod.Alt | KeyCode.PageDown,
linux: { primary: 0 }
});
registerCommand(new CoreCommand({
id: H.CursorColumnSelectLeft,
precondition: null,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyMod.Alt | KeyCode.LeftArrow,
linux: { primary: 0 }
}
}));
registerCommand(new CoreCommand({
id: H.CursorColumnSelectRight,
precondition: null,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyMod.Alt | KeyCode.RightArrow,
linux: { primary: 0 }
}
}));
registerCommand(new CoreCommand({
id: H.CursorColumnSelectUp,
precondition: null,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyMod.Alt | KeyCode.UpArrow,
linux: { primary: 0 }
}
}));
registerCommand(new CoreCommand({
id: H.CursorColumnSelectPageUp,
precondition: null,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyMod.Alt | KeyCode.PageUp,
linux: { primary: 0 }
}
}));
registerCommand(new CoreCommand({
id: H.CursorColumnSelectDown,
precondition: null,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyMod.Alt | KeyCode.DownArrow,
linux: { primary: 0 }
}
}));
registerCommand(new CoreCommand({
id: H.CursorColumnSelectPageDown,
precondition: null,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyMod.Alt | KeyCode.PageDown,
linux: { primary: 0 }
}
}));
registerCoreCommand(H.Tab, {
primary: KeyCode.Tab
}, KeybindingsRegistry.WEIGHT.editorCore(), KbExpr.and(
EditorContextKeys.TextFocus,
EditorContextKeys.TabDoesNotMoveFocus
));
registerCoreCommand(H.Outdent, {
primary: KeyMod.Shift | KeyCode.Tab
}, KeybindingsRegistry.WEIGHT.editorCore(), KbExpr.and(
EditorContextKeys.TextFocus,
EditorContextKeys.TabDoesNotMoveFocus
));
registerCommand(new CoreCommand({
id: H.Tab,
precondition: EditorContextKeys.Writable,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: KbExpr.and(
EditorContextKeys.TextFocus,
EditorContextKeys.TabDoesNotMoveFocus
),
primary: KeyCode.Tab
}
}));
registerCommand(new CoreCommand({
id: H.Outdent,
precondition: EditorContextKeys.Writable,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: KbExpr.and(
EditorContextKeys.TextFocus,
EditorContextKeys.TabDoesNotMoveFocus
),
primary: KeyMod.Shift | KeyCode.Tab
}
}));
registerCoreCommand(H.DeleteLeft, {
primary: KeyCode.Backspace,
secondary: [KeyMod.Shift | KeyCode.Backspace],
mac: { primary: KeyCode.Backspace, secondary: [KeyMod.Shift | KeyCode.Backspace, KeyMod.WinCtrl | KeyCode.KEY_H, KeyMod.WinCtrl | KeyCode.Backspace] }
});
registerCoreCommand(H.DeleteRight, {
primary: KeyCode.Delete,
mac: { primary: KeyCode.Delete, secondary: [KeyMod.WinCtrl | KeyCode.KEY_D, KeyMod.WinCtrl | KeyCode.Delete] }
});
registerCoreCommand(H.DeleteAllLeft, {
primary: null,
mac: { primary: KeyMod.CtrlCmd | KeyCode.Backspace }
});
registerCoreCommand(H.DeleteAllRight, {
primary: null,
mac: { primary: KeyMod.WinCtrl | KeyCode.KEY_K, secondary: [KeyMod.CtrlCmd | KeyCode.Delete] }
});
function registerWordCommand(handlerId: string, shift:boolean, key:KeyCode): void {
registerCoreCommand(handlerId, {
primary: getWordNavigationKB(shift, key),
mac: { primary: getMacWordNavigationKB(shift, key) }
});
}
registerWordCommand(H.CursorWordStartLeft, false, KeyCode.LeftArrow);
registerCoreCommand(H.CursorWordEndLeft, { primary: 0 });
registerCoreCommand(H.CursorWordLeft, { primary: 0 });
registerWordCommand(H.CursorWordStartLeftSelect, true, KeyCode.LeftArrow);
registerCoreCommand(H.CursorWordEndLeftSelect, { primary: 0 });
registerCoreCommand(H.CursorWordLeftSelect, { primary: 0 });
registerWordCommand(H.CursorWordEndRight, false, KeyCode.RightArrow);
registerCoreCommand(H.CursorWordStartRight, { primary: 0 });
registerCoreCommand(H.CursorWordRight, { primary: 0 });
registerWordCommand(H.CursorWordEndRightSelect, true, KeyCode.RightArrow);
registerCoreCommand(H.CursorWordStartRightSelect, { primary: 0 });
registerCoreCommand(H.CursorWordRightSelect, { primary: 0 });
registerWordCommand(H.DeleteWordLeft, false, KeyCode.Backspace);
registerCoreCommand(H.DeleteWordStartLeft, { primary: 0 });
registerCoreCommand(H.DeleteWordEndLeft, { primary: 0 });
registerWordCommand(H.DeleteWordRight, false, KeyCode.Delete);
registerCoreCommand(H.DeleteWordStartRight, { primary: 0 });
registerCoreCommand(H.DeleteWordEndRight, { primary: 0 });
registerCoreCommand(H.CancelSelection, {
primary: KeyCode.Escape,
secondary: [KeyMod.Shift | KeyCode.Escape]
}, KeybindingsRegistry.WEIGHT.editorCore(), KbExpr.and(
EditorContextKeys.TextFocus,
EditorContextKeys.HasNonEmptySelection
));
registerCoreCommand(H.RemoveSecondaryCursors, {
primary: KeyCode.Escape,
secondary: [KeyMod.Shift | KeyCode.Escape]
}, KeybindingsRegistry.WEIGHT.editorCore(1), KbExpr.and(
EditorContextKeys.TextFocus,
EditorContextKeys.HasMultipleSelections
));
registerCoreCommand(H.CursorTop, {
primary: KeyMod.CtrlCmd | KeyCode.Home,
mac: { primary: KeyMod.CtrlCmd | KeyCode.UpArrow }
});
registerCoreCommand(H.CursorTopSelect, {
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.Home,
mac: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.UpArrow }
});
registerCoreCommand(H.CursorBottom, {
primary: KeyMod.CtrlCmd | KeyCode.End,
mac: { primary: KeyMod.CtrlCmd | KeyCode.DownArrow }
});
registerCoreCommand(H.CursorBottomSelect, {
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.End,
mac: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.DownArrow }
});
registerCoreCommand(H.LineBreakInsert, {
primary: null,
mac: { primary: KeyMod.WinCtrl | KeyCode.KEY_O }
});
registerCoreCommand(H.Undo, {
primary: KeyMod.CtrlCmd | KeyCode.KEY_Z
});
registerCoreCommand(H.CursorUndo, {
primary: KeyMod.CtrlCmd | KeyCode.KEY_U
});
registerCoreCommand(H.Redo, {
primary: KeyMod.CtrlCmd | KeyCode.KEY_Y,
secondary: [KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_Z],
mac: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_Z }
});
registerCommand(new CoreCommand({
id: H.DeleteLeft,
precondition: EditorContextKeys.Writable,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.TextFocus,
primary: KeyCode.Backspace,
secondary: [KeyMod.Shift | KeyCode.Backspace],
mac: { primary: KeyCode.Backspace, secondary: [KeyMod.Shift | KeyCode.Backspace, KeyMod.WinCtrl | KeyCode.KEY_H, KeyMod.WinCtrl | KeyCode.Backspace] }
}
}));
registerCommand(new CoreCommand({
id: H.DeleteRight,
precondition: EditorContextKeys.Writable,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.TextFocus,
primary: KeyCode.Delete,
mac: { primary: KeyCode.Delete, secondary: [KeyMod.WinCtrl | KeyCode.KEY_D, KeyMod.WinCtrl | KeyCode.Delete] }
}
}));
registerCommand(new CoreCommand({
id: H.DeleteAllLeft,
precondition: EditorContextKeys.Writable,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.TextFocus,
primary: null,
mac: { primary: KeyMod.CtrlCmd | KeyCode.Backspace }
}
}));
registerCommand(new CoreCommand({
id: H.DeleteAllRight,
precondition: EditorContextKeys.Writable,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.TextFocus,
primary: null,
mac: { primary: KeyMod.WinCtrl | KeyCode.KEY_K, secondary: [KeyMod.CtrlCmd | KeyCode.Delete] }
}
}));
function selectAll(accessor: ServicesAccessor, args: any): void {
let HANDLER = editorCommon.Handler.SelectAll;
registerCommand(new WordCommand(H.CursorWordStartLeft, false, KeyCode.LeftArrow));
registerCommand(new UnboundCoreCommand(H.CursorWordEndLeft));
registerCommand(new UnboundCoreCommand(H.CursorWordLeft));
let focusedEditor = findFocusedEditor(HANDLER, accessor, false);
// Only if editor text focus (i.e. not if editor has widget focus).
if (focusedEditor && focusedEditor.isFocused()) {
focusedEditor.trigger('keyboard', HANDLER, args);
return;
registerCommand(new WordCommand(H.CursorWordStartLeftSelect, true, KeyCode.LeftArrow));
registerCommand(new UnboundCoreCommand(H.CursorWordEndLeftSelect));
registerCommand(new UnboundCoreCommand(H.CursorWordLeftSelect));
registerCommand(new WordCommand(H.CursorWordEndRight, false, KeyCode.RightArrow));
registerCommand(new UnboundCoreCommand(H.CursorWordStartRight));
registerCommand(new UnboundCoreCommand(H.CursorWordRight));
registerCommand(new WordCommand(H.CursorWordEndRightSelect, true, KeyCode.RightArrow));
registerCommand(new UnboundCoreCommand(H.CursorWordStartRightSelect));
registerCommand(new UnboundCoreCommand(H.CursorWordRightSelect));
registerCommand(new WordCommand(H.DeleteWordLeft, false, KeyCode.Backspace, EditorContextKeys.Writable));
registerCommand(new UnboundCoreCommand(H.DeleteWordStartLeft, EditorContextKeys.Writable));
registerCommand(new UnboundCoreCommand(H.DeleteWordEndLeft, EditorContextKeys.Writable));
registerCommand(new WordCommand(H.DeleteWordRight, false, KeyCode.Delete, EditorContextKeys.Writable));
registerCommand(new UnboundCoreCommand(H.DeleteWordStartRight, EditorContextKeys.Writable));
registerCommand(new UnboundCoreCommand(H.DeleteWordEndRight, EditorContextKeys.Writable));
registerCommand(new CoreCommand({
id: H.CancelSelection,
precondition: EditorContextKeys.HasNonEmptySelection,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.TextFocus,
primary: KeyCode.Escape,
secondary: [KeyMod.Shift | KeyCode.Escape]
}
}));
registerCommand(new CoreCommand({
id: H.RemoveSecondaryCursors,
precondition: EditorContextKeys.HasMultipleSelections,
kbOpts: {
weight: CORE_WEIGHT + 1,
kbExpr: EditorContextKeys.TextFocus,
primary: KeyCode.Escape,
secondary: [KeyMod.Shift | KeyCode.Escape]
}
}));
registerCommand(new CoreCommand({
id: H.CursorTop,
precondition: null,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.CtrlCmd | KeyCode.Home,
mac: { primary: KeyMod.CtrlCmd | KeyCode.UpArrow }
}
}));
registerCommand(new CoreCommand({
id: H.CursorTopSelect,
precondition: null,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.Home,
mac: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.UpArrow }
}
}));
registerCommand(new CoreCommand({
id: H.CursorBottom,
precondition: null,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.CtrlCmd | KeyCode.End,
mac: { primary: KeyMod.CtrlCmd | KeyCode.DownArrow }
}
}));
registerCommand(new CoreCommand({
id: H.CursorBottomSelect,
precondition: null,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.End,
mac: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.DownArrow }
}
}));
registerCommand(new CoreCommand({
id: H.LineBreakInsert,
precondition: EditorContextKeys.Writable,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.TextFocus,
primary: null,
mac: { primary: KeyMod.WinCtrl | KeyCode.KEY_O }
}
}));
registerCommand(new CoreCommand({
id: H.Undo,
precondition: EditorContextKeys.Writable,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.CtrlCmd | KeyCode.KEY_Z
}
}));
registerCommand(new CoreCommand({
id: H.CursorUndo,
precondition: null,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.CtrlCmd | KeyCode.KEY_U
}
}));
registerCommand(new CoreCommand({
id: H.Redo,
precondition: EditorContextKeys.Writable,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.CtrlCmd | KeyCode.KEY_Y,
secondary: [KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_Z],
mac: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_Z }
}
}));
class SelectAllCommand extends Command {
constructor() {
super({
id: 'editor.action.selectAll',
precondition: null,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.CtrlCmd | KeyCode.KEY_A
}
});
}
// Ignore this action when user is focussed on an element that allows for entering text
let activeElement = <HTMLElement>document.activeElement;
if (activeElement && ['input', 'textarea'].indexOf(activeElement.tagName.toLowerCase()) >= 0) {
(<any>activeElement).select();
return;
}
public runCommand(accessor:ServicesAccessor, args: any): void {
let HANDLER = editorCommon.Handler.SelectAll;
// Redirecting to last active editor
let activeEditor = getActiveEditor(accessor);
if (activeEditor) {
activeEditor.focus();
activeEditor.trigger('keyboard', HANDLER, args);
return;
let focusedEditor = findFocusedEditor(HANDLER, accessor, false);
// Only if editor text focus (i.e. not if editor has widget focus).
if (focusedEditor && focusedEditor.isFocused()) {
focusedEditor.trigger('keyboard', HANDLER, args);
return;
}
// Ignore this action when user is focussed on an element that allows for entering text
let activeElement = <HTMLElement>document.activeElement;
if (activeElement && ['input', 'textarea'].indexOf(activeElement.tagName.toLowerCase()) >= 0) {
(<any>activeElement).select();
return;
}
// Redirecting to last active editor
let activeEditor = getActiveEditor(accessor);
if (activeEditor) {
activeEditor.focus();
activeEditor.trigger('keyboard', HANDLER, args);
return;
}
}
}
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: 'editor.action.selectAll',
handler: selectAll,
weight: KeybindingsRegistry.WEIGHT.editorCore(),
when: EditorContextKeys.TextFocus,
primary: KeyMod.CtrlCmd | KeyCode.KEY_A
});
registerCommand(new SelectAllCommand());

View file

@ -13,7 +13,7 @@ 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 {Command as ConfigBasicCommand, EditorCommand as ConfigEditorCommand} from 'vs/editor/common/config/config';
import {ICommandOptions, 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';
@ -22,6 +22,7 @@ import {MenuId, MenuRegistry} from 'vs/platform/actions/common/actions';
export type ServicesAccessor = ServicesAccessor;
export const Command = ConfigBasicCommand;
export const EditorCommand = ConfigEditorCommand;
export type ICommandOptions = ICommandOptions;
// --- Keybinding extensions to make it more concise to express keybindings conditions
export interface IEditorCommandMenuOptions {
@ -33,52 +34,13 @@ export interface IEditorCommandMenuOptions {
// --- Editor Actions
// let recorded: EditorAction[] = [];
function record(desc:EditorAction) {
return;
// let stack = new Error().stack;
// desc.callsite = stack.split('\n')[3];
// recorded.push(desc);
}
function analyze() {
return;
// recorded.sort((a, b) => a.id < b.id ? -1 : (a.id > b.id ? 1 : 0));
// recorded.forEach((desc) => {
// let rightpad = (str:string, cnt:number) => {
// while (str.length < cnt) {
// str = str + ' ';
// }
// return str;
// };
// if (typeof desc._precondition === 'undefined') {
// console.warn('MISSING PRECONDITION FOR ' + desc.id + desc.callsite);
// } else {
// let prec = desc._precondition ? desc._precondition.serialize() : 'null';
// if (prec.indexOf('editorTextFocus') >= 0 || prec.indexOf('editorFocus') >= 0) {
// console.warn('BELOW COMMAND WANTS FOCUS!!!');
// }
// if (desc._needsWritableEditor && prec.indexOf('!editorReadonly') === -1) {
// console.warn('BELOW COMMAND DOES NOT PRECONDITION CORRECTLY WRITABLE!');
// }
// console.log(rightpad(desc.id, 50) + '' + desc._needsWritableEditor + '\t\t' + rightpad(prec, 50) + '\t\t' + desc.callsite);
// }
// });
// recorded = [];
}
export module CommonEditorRegistry {
export function registerEditorAction(desc:EditorAction) {
if (desc.kbOpts && desc.kbOpts.kbExpr && desc._precondition) {
desc.kbOpts.kbExpr = KbExpr.and(desc.kbOpts.kbExpr, desc._precondition);
}
record(desc);
(<EditorContributionRegistry>Registry.as(Extensions.EditorCommonContributions)).registerEditorAction(desc);
}
export function getEditorActions(): EditorAction[] {
analyze();
return (<EditorContributionRegistry>Registry.as(Extensions.EditorCommonContributions)).getEditorActions();
}
@ -183,22 +145,23 @@ class EditorContributionRegistry {
}
Registry.add(Extensions.EditorCommonContributions, new EditorContributionRegistry());
export abstract class EditorAction extends ConfigEditorCommand {
export interface IActionOptions extends ICommandOptions {
label: string;
alias: string;
menuOpts?: IEditorCommandMenuOptions;
}
private _needsWritableEditor: boolean;
export abstract class EditorAction extends ConfigEditorCommand {
public label: string;
public alias: string;
public menuOpts: IEditorCommandMenuOptions;
public _precondition: KbExpr;
constructor(id:string, label:string, alias:string, needsWritableEditor:boolean) {
super(id);
this.label = label;
this.alias = alias;
this._needsWritableEditor = needsWritableEditor;
this.menuOpts = null;
constructor(opts:IActionOptions) {
super(opts);
this.label = opts.label;
this.alias = opts.alias;
this.menuOpts = opts.menuOpts;
}
protected runEditorCommand(accessor:ServicesAccessor, editor: editorCommon.ICommonCodeEditor, args: any): void | TPromise<void> {
@ -214,9 +177,6 @@ export abstract class EditorAction extends ConfigEditorCommand {
if (!this.supported(accessor, editor, false)) {
return false;
}
if (this._needsWritableEditor) {
return !editor.getConfiguration().readOnly;
}
return true;
}
@ -230,18 +190,22 @@ export abstract class EditorAction extends ConfigEditorCommand {
};
}
return kbService.contextMatchesRules(this._precondition, override);
return kbService.contextMatchesRules(this.precondition, override);
}
public abstract run(accessor:ServicesAccessor, editor:editorCommon.ICommonCodeEditor): void | TPromise<void>;
}
export interface IHandlerActionOptions extends IActionOptions {
handlerId: string;
}
export abstract class HandlerEditorAction extends EditorAction {
private _handlerId: string;
constructor(id:string, label:string, alias:string, needsWritableEditor:boolean, handlerId: string) {
super(id, label, alias, needsWritableEditor);
this._handlerId = handlerId;
constructor(opts: IHandlerActionOptions) {
super(opts);
this._handlerId = opts.handlerId;
}
public run(accessor:ServicesAccessor, editor:editorCommon.ICommonCodeEditor): void {

View file

@ -15,7 +15,7 @@ import {renderHtml} from 'vs/base/browser/htmlContentRenderer';
import {StyleMutator} from 'vs/base/browser/styleMutator';
import {Widget} from 'vs/base/browser/ui/widget';
import {ServicesAccessor} from 'vs/platform/instantiation/common/instantiation';
import {KbExpr, KbCtxKey, IKeybindingContextKey, IKeybindingService} from 'vs/platform/keybinding/common/keybinding';
import {KbCtxKey, IKeybindingContextKey, IKeybindingService} from 'vs/platform/keybinding/common/keybinding';
import {KeybindingsRegistry} from 'vs/platform/keybinding/common/keybindingsRegistry';
import {GlobalScreenReaderNVDA} from 'vs/editor/common/config/commonEditorConfig';
import {ICommonCodeEditor, IEditorContribution, EditorContextKeys} from 'vs/editor/common/editorCommon';
@ -192,19 +192,16 @@ class AccessibilityHelpWidget extends Widget implements IOverlayWidget {
class ShowAccessibilityHelpAction extends EditorAction {
constructor() {
super(
'editor.action.showAccessibilityHelp',
nls.localize('ShowAccessibilityHelpAction',"Show Accessibility Help"),
'Show Accessibility Help',
false
);
this._precondition = null;
this.kbOpts = {
kbExpr: EditorContextKeys.Focus,
primary: KeyMod.Alt | KeyCode.F1
};
super({
id: 'editor.action.showAccessibilityHelp',
label: nls.localize('ShowAccessibilityHelpAction',"Show Accessibility Help"),
alias: 'Show Accessibility Help',
precondition: null,
kbOpts: {
kbExpr: EditorContextKeys.Focus,
primary: KeyMod.Alt | KeyCode.F1
}
});
}
public run(accessor:ServicesAccessor, editor:ICommonCodeEditor): void {
@ -216,31 +213,30 @@ class ShowAccessibilityHelpAction extends EditorAction {
EditorBrowserRegistry.registerEditorContribution(AccessibilityHelpController);
CommonEditorRegistry.registerEditorAction(new ShowAccessibilityHelpAction());
const AccessibilityHelpCommand = EditorCommand.bindToContribution<AccessibilityHelpController>(
AccessibilityHelpController.get,
{
weight: CommonEditorRegistry.commandWeight(100),
kbExpr: KbExpr.and(EditorContextKeys.Focus, CONTEXT_ACCESSIBILITY_WIDGET_VISIBLE)
}
);
const AccessibilityHelpCommand = EditorCommand.bindToContribution<AccessibilityHelpController>(AccessibilityHelpController.get);
CommonEditorRegistry.registerEditorCommand2(new AccessibilityHelpCommand(
'closeAccessibilityHelp',
x => x.hide(),
{
CommonEditorRegistry.registerEditorCommand2(new AccessibilityHelpCommand({
id: 'closeAccessibilityHelp',
precondition: CONTEXT_ACCESSIBILITY_WIDGET_VISIBLE,
handler: x => x.hide(),
kbOpts: {
weight: CommonEditorRegistry.commandWeight(100),
kbExpr: EditorContextKeys.Focus,
primary: KeyCode.Escape, secondary: [KeyMod.Shift | KeyCode.Escape]
}
));
}));
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
};
super({
id: TOGGLE_EXPERIMENTAL_SCREEN_READER_SUPPORT_COMMAND_ID,
precondition: null,
kbOpts: {
weight: KeybindingsRegistry.WEIGHT.workbenchContrib(),
kbExpr: null,
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_R
}
});
}
public runCommand(accessor:ServicesAccessor, args: any): void {

View file

@ -6,17 +6,15 @@
import * as nls from 'vs/nls';
import {ICommand, ICommonCodeEditor, EditorContextKeys} from 'vs/editor/common/editorCommon';
import {EditorAction, CommonEditorRegistry, ServicesAccessor} from 'vs/editor/common/editorCommonExtensions';
import {IActionOptions, EditorAction, CommonEditorRegistry, ServicesAccessor} from 'vs/editor/common/editorCommonExtensions';
import {MoveCarretCommand} from './moveCarretCommand';
class MoveCarretAction extends EditorAction {
private left:boolean;
constructor(id:string, label:string, alias:string, left:boolean) {
super(id, label, alias, true);
this._precondition = EditorContextKeys.Writable;
constructor(left:boolean, opts:IActionOptions) {
super(opts);
this.left = left;
}
@ -37,24 +35,24 @@ class MoveCarretAction extends EditorAction {
class MoveCarretLeftAction extends MoveCarretAction {
constructor() {
super(
'editor.action.moveCarretLeftAction',
nls.localize('carret.moveLeft', "Move Carret Left"),
'Move Carret Left',
true
);
super(true, {
id: 'editor.action.moveCarretLeftAction',
label: nls.localize('carret.moveLeft', "Move Carret Left"),
alias: 'Move Carret Left',
precondition: EditorContextKeys.Writable
});
}
}
class MoveCarretRightAction extends MoveCarretAction {
constructor() {
super(
'editor.action.moveCarretRightAction',
nls.localize('carret.moveRight', "Move Carret Right"),
'Move Carret Right',
false
);
super(false, {
id: 'editor.action.moveCarretRightAction',
label: nls.localize('carret.moveRight', "Move Carret Right"),
alias: 'Move Carret Right',
precondition: EditorContextKeys.Writable
});
}
}

View file

@ -12,7 +12,7 @@ import * as browser from 'vs/base/browser/browser';
import {ServicesAccessor} from 'vs/platform/instantiation/common/instantiation';
import {findFocusedEditor} from 'vs/editor/common/config/config';
import * as editorCommon from 'vs/editor/common/editorCommon';
import {EditorAction, CommonEditorRegistry} from 'vs/editor/common/editorCommonExtensions';
import {IActionOptions, EditorAction, CommonEditorRegistry} from 'vs/editor/common/editorCommonExtensions';
import {MenuId} from 'vs/platform/actions/common/actions';
import EditorContextKeys = editorCommon.EditorContextKeys;
@ -23,8 +23,8 @@ abstract class ExecCommandAction extends EditorAction {
private browserCommand:string;
constructor(id:string, label:string, alias:string, needsWritableEditor:boolean, browserCommand:string) {
super(id, label, alias, needsWritableEditor);
constructor(browserCommand:string, opts:IActionOptions) {
super(opts);
this.browserCommand = browserCommand;
}
@ -48,28 +48,23 @@ abstract class ExecCommandAction extends EditorAction {
class ExecCommandCutAction extends ExecCommandAction {
constructor() {
super(
'editor.action.clipboardCutAction',
nls.localize('actions.clipboard.cutLabel', "Cut"),
'Cut',
true,
'cut'
);
this._precondition = EditorContextKeys.Writable;
this.kbOpts = {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.CtrlCmd | KeyCode.KEY_X,
win: { primary: KeyMod.CtrlCmd | KeyCode.KEY_X, secondary: [KeyMod.Shift | KeyCode.Delete] }
};
this.menuOpts = {
kbExpr: EditorContextKeys.Writable,
menu: MenuId.EditorContext,
group: CLIPBOARD_CONTEXT_MENU_GROUP,
order: 1
};
super('cut', {
id: 'editor.action.clipboardCutAction',
label: nls.localize('actions.clipboard.cutLabel', "Cut"),
alias: 'Cut',
precondition: EditorContextKeys.Writable,
kbOpts: {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.CtrlCmd | KeyCode.KEY_X,
win: { primary: KeyMod.CtrlCmd | KeyCode.KEY_X, secondary: [KeyMod.Shift | KeyCode.Delete] }
},
menuOpts: {
kbExpr: EditorContextKeys.Writable,
menu: MenuId.EditorContext,
group: CLIPBOARD_CONTEXT_MENU_GROUP,
order: 1
}
});
}
public run(accessor:ServicesAccessor, editor:editorCommon.ICommonCodeEditor): void {
@ -84,28 +79,23 @@ class ExecCommandCutAction extends ExecCommandAction {
class ExecCommandCopyAction extends ExecCommandAction {
constructor() {
super(
'editor.action.clipboardCopyAction',
nls.localize('actions.clipboard.copyLabel', "Copy"),
'Copy',
false,
'copy'
);
this._precondition = null;
this.kbOpts = {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.CtrlCmd | KeyCode.KEY_C,
win: { primary: KeyMod.CtrlCmd | KeyCode.KEY_C, secondary: [KeyMod.CtrlCmd | KeyCode.Insert] }
};
this.menuOpts = {
kbExpr: null,
menu: MenuId.EditorContext,
group: CLIPBOARD_CONTEXT_MENU_GROUP,
order: 2
};
super('copy', {
id: 'editor.action.clipboardCopyAction',
label: nls.localize('actions.clipboard.copyLabel', "Copy"),
alias: 'Copy',
precondition: null,
kbOpts: {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.CtrlCmd | KeyCode.KEY_C,
win: { primary: KeyMod.CtrlCmd | KeyCode.KEY_C, secondary: [KeyMod.CtrlCmd | KeyCode.Insert] }
},
menuOpts: {
kbExpr: null,
menu: MenuId.EditorContext,
group: CLIPBOARD_CONTEXT_MENU_GROUP,
order: 2
}
});
}
public run(accessor:ServicesAccessor, editor:editorCommon.ICommonCodeEditor): void {
@ -120,28 +110,23 @@ class ExecCommandCopyAction extends ExecCommandAction {
class ExecCommandPasteAction extends ExecCommandAction {
constructor() {
super(
'editor.action.clipboardPasteAction',
nls.localize('actions.clipboard.pasteLabel', "Paste"),
'Paste',
true,
'paste'
);
this._precondition = EditorContextKeys.Writable;
this.kbOpts = {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.CtrlCmd | KeyCode.KEY_V,
win: { primary: KeyMod.CtrlCmd | KeyCode.KEY_V, secondary: [KeyMod.Shift | KeyCode.Insert] }
};
this.menuOpts = {
kbExpr: EditorContextKeys.Writable,
menu: MenuId.EditorContext,
group: CLIPBOARD_CONTEXT_MENU_GROUP,
order: 3
};
super('paste', {
id: 'editor.action.clipboardPasteAction',
label: nls.localize('actions.clipboard.pasteLabel', "Paste"),
alias: 'Paste',
precondition: EditorContextKeys.Writable,
kbOpts: {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.CtrlCmd | KeyCode.KEY_V,
win: { primary: KeyMod.CtrlCmd | KeyCode.KEY_V, secondary: [KeyMod.Shift | KeyCode.Insert] }
},
menuOpts: {
kbExpr: EditorContextKeys.Writable,
menu: MenuId.EditorContext,
group: CLIPBOARD_CONTEXT_MENU_GROUP,
order: 3
}
});
}
}

View file

@ -7,7 +7,7 @@
import * as nls from 'vs/nls';
import {KeyCode, KeyMod} from 'vs/base/common/keyCodes';
import {ICommand, ICommonCodeEditor, EditorContextKeys} from 'vs/editor/common/editorCommon';
import {EditorAction, CommonEditorRegistry, ServicesAccessor} from 'vs/editor/common/editorCommonExtensions';
import {IActionOptions, EditorAction, CommonEditorRegistry, ServicesAccessor} from 'vs/editor/common/editorCommonExtensions';
import {BlockCommentCommand} from './blockCommentCommand';
import {LineCommentCommand, Type} from './lineCommentCommand';
@ -15,8 +15,8 @@ abstract class CommentLineAction extends EditorAction {
private _type: Type;
constructor(id:string, label:string, alias:string, type:Type) {
super(id, label, alias, true);
constructor(type:Type, opts:IActionOptions) {
super(opts);
this._type = type;
}
@ -40,79 +40,64 @@ abstract class CommentLineAction extends EditorAction {
}
class ToggleCommentLineAction extends CommentLineAction {
constructor() {
super(
'editor.action.commentLine',
nls.localize('comment.line', "Toggle Line Comment"),
'Toggle Line Comment',
Type.Toggle
);
this._precondition = EditorContextKeys.Writable;
this.kbOpts = {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.CtrlCmd | KeyCode.US_SLASH
};
super(Type.Toggle, {
id: 'editor.action.commentLine',
label: nls.localize('comment.line', "Toggle Line Comment"),
alias: 'Toggle Line Comment',
precondition: EditorContextKeys.Writable,
kbOpts: {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.CtrlCmd | KeyCode.US_SLASH
}
});
}
}
class AddLineCommentAction extends CommentLineAction {
constructor() {
super(
'editor.action.addCommentLine',
nls.localize('comment.line.add', "Add Line Comment"),
'Add Line Comment',
Type.ForceAdd
);
this._precondition = EditorContextKeys.Writable;
this.kbOpts = {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.chord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_C)
};
super(Type.ForceAdd, {
id: 'editor.action.addCommentLine',
label: nls.localize('comment.line.add', "Add Line Comment"),
alias: 'Add Line Comment',
precondition: EditorContextKeys.Writable,
kbOpts: {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.chord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_C)
}
});
}
}
class RemoveLineCommentAction extends CommentLineAction {
constructor() {
super(
'editor.action.removeCommentLine',
nls.localize('comment.line.remove', "Remove Line Comment"),
'Remove Line Comment',
Type.ForceRemove
);
this._precondition = EditorContextKeys.Writable;
this.kbOpts = {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.chord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_U)
};
super(Type.ForceRemove, {
id: 'editor.action.removeCommentLine',
label: nls.localize('comment.line.remove', "Remove Line Comment"),
alias: 'Remove Line Comment',
precondition: EditorContextKeys.Writable
kbOpts: {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.chord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_U)
}
});
}
}
class BlockCommentAction extends EditorAction {
constructor() {
super(
'editor.action.blockComment',
nls.localize('comment.block', "Toggle Block Comment"),
'Toggle Block Comment',
true
);
this._precondition = EditorContextKeys.Writable;
this.kbOpts = {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.Shift | KeyMod.Alt | KeyCode.KEY_A,
linux: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_A }
};
super({
id: 'editor.action.blockComment',
label: nls.localize('comment.block', "Toggle Block Comment"),
alias: 'Toggle Block Comment',
precondition: EditorContextKeys.Writable,
kbOpts: {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.Shift | KeyMod.Alt | KeyCode.KEY_A,
linux: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_A }
}
});
}
public run(accessor:ServicesAccessor, editor:ICommonCodeEditor): void {

View file

@ -225,19 +225,16 @@ class ContextMenuController implements IEditorContribution {
class ShowContextMenu extends EditorAction {
constructor() {
super(
'editor.action.showContextMenu',
nls.localize('action.showContextMenu.label', "Show Editor Context Menu"),
'Show Editor Context Menu',
false
);
this._precondition = null;
this.kbOpts = {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.Shift | KeyCode.F10
};
super({
id: 'editor.action.showContextMenu',
label: nls.localize('action.showContextMenu.label', "Show Editor Context Menu"),
alias: 'Show Editor Context Menu',
precondition: null,
kbOpts: {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.Shift | KeyCode.F10
}
});
}
public run(accessor:ServicesAccessor, editor:ICommonCodeEditor): void {

View file

@ -450,19 +450,16 @@ export class DefineKeybindingAction extends EditorAction {
static ID = 'editor.action.defineKeybinding';
constructor() {
super(
DefineKeybindingAction.ID,
nls.localize('DefineKeybindingAction',"Define Keybinding"),
'Define Keybinding',
true
);
this._precondition = KbExpr.and(EditorContextKeys.Writable, EditorContextKeys.LanguageId.isEqualTo('json'));
this.kbOpts = {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.chord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_K)
};
super({
id: DefineKeybindingAction.ID,
label: nls.localize('DefineKeybindingAction',"Define Keybinding"),
alias: 'Define Keybinding',
precondition: KbExpr.and(EditorContextKeys.Writable, EditorContextKeys.LanguageId.isEqualTo('json')),
kbOpts: {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.chord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_K)
}
});
}
public run(accessor:ServicesAccessor, editor:editorCommon.ICommonCodeEditor): void {

View file

@ -34,7 +34,7 @@ export interface IFindStartOptions {
}
export const CONTEXT_FIND_WIDGET_VISIBLE = new KbCtxKey<boolean>('findWidgetVisible', false);
export const CONTEXT_FIND_WIDGET_NOT_VISIBLE = CONTEXT_FIND_WIDGET_VISIBLE.toNegated();
export const CONTEXT_FIND_WIDGET_NOT_VISIBLE: KbExpr = CONTEXT_FIND_WIDGET_VISIBLE.toNegated();
export class CommonFindController extends Disposable implements editorCommon.IEditorContribution {
@ -236,19 +236,16 @@ export class CommonFindController extends Disposable implements editorCommon.IEd
export class StartFindAction extends EditorAction {
constructor() {
super(
FIND_IDS.StartFindAction,
nls.localize('startFindAction',"Find"),
'Find',
false
);
this._precondition = null;
this.kbOpts = {
kbExpr: null,
primary: KeyMod.CtrlCmd | KeyCode.KEY_F
};
super({
id: FIND_IDS.StartFindAction,
label: nls.localize('startFindAction',"Find"),
alias: 'Find',
precondition: null,
kbOpts: {
kbExpr: null,
primary: KeyMod.CtrlCmd | KeyCode.KEY_F
}
});
}
public run(accessor:ServicesAccessor, editor:editorCommon.ICommonCodeEditor): void {
@ -263,10 +260,6 @@ export class StartFindAction extends EditorAction {
}
export abstract class MatchFindAction extends EditorAction {
constructor(id:string, label:string, alias:string) {
super(id, label, alias, false);
}
public run(accessor:ServicesAccessor, editor:editorCommon.ICommonCodeEditor): void {
let controller = CommonFindController.getFindController(editor);
if (!this._run(controller)) {
@ -286,19 +279,17 @@ export abstract class MatchFindAction extends EditorAction {
export class NextMatchFindAction extends MatchFindAction {
constructor() {
super(
FIND_IDS.NextMatchFindAction,
nls.localize('findNextMatchAction', "Find Next"),
'Find Next'
);
this._precondition = null;
this.kbOpts = {
kbExpr: EditorContextKeys.Focus,
primary: KeyCode.F3,
mac: { primary: KeyMod.CtrlCmd | KeyCode.KEY_G, secondary: [KeyCode.F3] }
};
super({
id: FIND_IDS.NextMatchFindAction,
label: nls.localize('findNextMatchAction', "Find Next"),
alias: 'Find Next',
precondition: null,
kbOpts: {
kbExpr: EditorContextKeys.Focus,
primary: KeyCode.F3,
mac: { primary: KeyMod.CtrlCmd | KeyCode.KEY_G, secondary: [KeyCode.F3] }
}
});
}
protected _run(controller:CommonFindController): boolean {
@ -309,19 +300,17 @@ export class NextMatchFindAction extends MatchFindAction {
export class PreviousMatchFindAction extends MatchFindAction {
constructor() {
super(
FIND_IDS.PreviousMatchFindAction,
nls.localize('findPreviousMatchAction', "Find Previous"),
'Find Previous'
);
this._precondition = null;
this.kbOpts = {
kbExpr: EditorContextKeys.Focus,
primary: KeyMod.Shift | KeyCode.F3,
mac: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_G, secondary: [KeyMod.Shift | KeyCode.F3] }
};
super({
id: FIND_IDS.PreviousMatchFindAction,
label: nls.localize('findPreviousMatchAction', "Find Previous"),
alias: 'Find Previous',
precondition: null,
kbOpts: {
kbExpr: EditorContextKeys.Focus,
primary: KeyMod.Shift | KeyCode.F3,
mac: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_G, secondary: [KeyMod.Shift | KeyCode.F3] }
}
});
}
protected _run(controller:CommonFindController): boolean {
@ -330,11 +319,6 @@ export class PreviousMatchFindAction extends MatchFindAction {
}
export abstract class SelectionMatchFindAction extends EditorAction {
constructor(id:string, label:string, alias:string) {
super(id, label, alias, false);
}
public run(accessor:ServicesAccessor, editor:editorCommon.ICommonCodeEditor): void {
let controller = CommonFindController.getFindController(editor);
let selectionSearchString = controller.getSelectionSearchString();
@ -358,18 +342,16 @@ export abstract class SelectionMatchFindAction extends EditorAction {
export class NextSelectionMatchFindAction extends SelectionMatchFindAction {
constructor() {
super(
FIND_IDS.NextSelectionMatchFindAction,
nls.localize('nextSelectionMatchFindAction', "Find Next Selection"),
'Find Next Selection'
);
this._precondition = null;
this.kbOpts = {
kbExpr: EditorContextKeys.Focus,
primary: KeyMod.CtrlCmd | KeyCode.F3
};
super({
id: FIND_IDS.NextSelectionMatchFindAction,
label: nls.localize('nextSelectionMatchFindAction', "Find Next Selection"),
alias: 'Find Next Selection',
precondition: null,
kbOpts: {
kbExpr: EditorContextKeys.Focus,
primary: KeyMod.CtrlCmd | KeyCode.F3
}
});
}
protected _run(controller:CommonFindController): boolean {
@ -380,18 +362,16 @@ export class NextSelectionMatchFindAction extends SelectionMatchFindAction {
export class PreviousSelectionMatchFindAction extends SelectionMatchFindAction {
constructor() {
super(
FIND_IDS.PreviousSelectionMatchFindAction,
nls.localize('previousSelectionMatchFindAction', "Find Previous Selection"),
'Find Previous Selection'
);
this._precondition = null;
this.kbOpts = {
kbExpr: EditorContextKeys.Focus,
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.F3
};
super({
id: FIND_IDS.PreviousSelectionMatchFindAction,
label: nls.localize('previousSelectionMatchFindAction', "Find Previous Selection"),
alias: 'Find Previous Selection',
precondition: null,
kbOpts: {
kbExpr: EditorContextKeys.Focus,
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.F3
}
});
}
protected _run(controller:CommonFindController): boolean {
@ -402,20 +382,17 @@ export class PreviousSelectionMatchFindAction extends SelectionMatchFindAction {
export class StartFindReplaceAction extends EditorAction {
constructor() {
super(
FIND_IDS.StartFindReplaceAction,
nls.localize('startReplace', "Replace"),
'Replace',
true
);
this._precondition = null;
this.kbOpts = {
kbExpr: null,
primary: KeyMod.CtrlCmd | KeyCode.KEY_H,
mac: { primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.KEY_F }
};
super({
id: FIND_IDS.StartFindReplaceAction,
label: nls.localize('startReplace', "Replace"),
alias: 'Replace',
precondition: null,
kbOpts: {
kbExpr: null,
primary: KeyMod.CtrlCmd | KeyCode.KEY_H,
mac: { primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.KEY_F }
}
});
}
public run(accessor:ServicesAccessor, editor:editorCommon.ICommonCodeEditor): void {
@ -492,11 +469,6 @@ function multiCursorFind(editor:editorCommon.ICommonCodeEditor, changeFindSearch
}
export abstract class SelectNextFindMatchAction extends EditorAction {
constructor(id:string, label:string, alias:string) {
super(id, label, alias, false);
}
protected _getNextMatch(editor:editorCommon.ICommonCodeEditor): Selection {
let r = multiCursorFind(editor, true);
if (!r) {
@ -520,11 +492,6 @@ export abstract class SelectNextFindMatchAction extends EditorAction {
}
export abstract class SelectPreviousFindMatchAction extends EditorAction {
constructor(id:string, label:string, alias:string) {
super(id, label, alias, false);
}
protected _getPreviousMatch(editor:editorCommon.ICommonCodeEditor): Selection {
let r = multiCursorFind(editor, true);
if (!r) {
@ -550,18 +517,16 @@ export abstract class SelectPreviousFindMatchAction extends EditorAction {
export class AddSelectionToNextFindMatchAction extends SelectNextFindMatchAction {
constructor() {
super(
FIND_IDS.AddSelectionToNextFindMatchAction,
nls.localize('addSelectionToNextFindMatch', "Add Selection To Next Find Match"),
'Add Selection To Next Find Match'
);
this._precondition = null;
this.kbOpts = {
kbExpr: EditorContextKeys.Focus,
primary: KeyMod.CtrlCmd | KeyCode.KEY_D
};
super({
id: FIND_IDS.AddSelectionToNextFindMatchAction,
label: nls.localize('addSelectionToNextFindMatch', "Add Selection To Next Find Match"),
alias: 'Add Selection To Next Find Match',
precondition: null,
kbOpts: {
kbExpr: EditorContextKeys.Focus,
primary: KeyMod.CtrlCmd | KeyCode.KEY_D
}
});
}
public run(accessor:ServicesAccessor, editor:editorCommon.ICommonCodeEditor): void {
@ -580,13 +545,12 @@ export class AddSelectionToNextFindMatchAction extends SelectNextFindMatchAction
export class AddSelectionToPreviousFindMatchAction extends SelectPreviousFindMatchAction {
constructor() {
super(
FIND_IDS.AddSelectionToPreviousFindMatchAction,
nls.localize('addSelectionToPreviousFindMatch', "Add Selection To Previous Find Match"),
'Add Selection To Previous Find Match'
);
this._precondition = null;
super({
id: FIND_IDS.AddSelectionToPreviousFindMatchAction,
label: nls.localize('addSelectionToPreviousFindMatch', "Add Selection To Previous Find Match"),
alias: 'Add Selection To Previous Find Match',
precondition: null
});
}
public run(accessor:ServicesAccessor, editor:editorCommon.ICommonCodeEditor): void {
@ -605,18 +569,16 @@ export class AddSelectionToPreviousFindMatchAction extends SelectPreviousFindMat
export class MoveSelectionToNextFindMatchAction extends SelectNextFindMatchAction {
constructor() {
super(
FIND_IDS.MoveSelectionToNextFindMatchAction,
nls.localize('moveSelectionToNextFindMatch', "Move Last Selection To Next Find Match"),
'Move Last Selection To Next Find Match'
);
this._precondition = null;
this.kbOpts = {
kbExpr: EditorContextKeys.Focus,
primary: KeyMod.chord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_D)
};
super({
id: FIND_IDS.MoveSelectionToNextFindMatchAction,
label: nls.localize('moveSelectionToNextFindMatch', "Move Last Selection To Next Find Match"),
alias: 'Move Last Selection To Next Find Match',
precondition: null,
kbOpts: {
kbExpr: EditorContextKeys.Focus,
primary: KeyMod.chord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_D)
}
});
}
public run(accessor:ServicesAccessor, editor:editorCommon.ICommonCodeEditor): void {
@ -635,13 +597,12 @@ export class MoveSelectionToNextFindMatchAction extends SelectNextFindMatchActio
export class MoveSelectionToPreviousFindMatchAction extends SelectPreviousFindMatchAction {
constructor() {
super(
FIND_IDS.MoveSelectionToPreviousFindMatchAction,
nls.localize('moveSelectionToPreviousFindMatch', "Move Last Selection To Previous Find Match"),
'Move Last Selection To Previous Find Match'
);
this._precondition = null;
super({
id: FIND_IDS.MoveSelectionToPreviousFindMatchAction,
label: nls.localize('moveSelectionToPreviousFindMatch', "Move Last Selection To Previous Find Match"),
alias: 'Move Last Selection To Previous Find Match',
precondition: null
});
}
public run(accessor:ServicesAccessor, editor:editorCommon.ICommonCodeEditor): void {
@ -658,11 +619,6 @@ export class MoveSelectionToPreviousFindMatchAction extends SelectPreviousFindMa
}
export abstract class AbstractSelectHighlightsAction extends EditorAction {
constructor(id:string, label:string, alias:string) {
super(id, label, alias, false);
}
public run(accessor:ServicesAccessor, editor:editorCommon.ICommonCodeEditor): void {
let r = multiCursorFind(editor, true);
if (!r) {
@ -690,41 +646,36 @@ export abstract class AbstractSelectHighlightsAction extends EditorAction {
export class SelectHighlightsAction extends AbstractSelectHighlightsAction {
constructor() {
super(
'editor.action.selectHighlights',
nls.localize('selectAllOccurencesOfFindMatch', "Select All Occurences of Find Match"),
'Select All Occurences of Find Match'
);
this._precondition = null;
this.kbOpts = {
kbExpr: EditorContextKeys.Focus,
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_L
};
super({
id: 'editor.action.selectHighlights',
label: nls.localize('selectAllOccurencesOfFindMatch', "Select All Occurences of Find Match"),
alias: 'Select All Occurences of Find Match',
precondition: null,
kbOpts: {
kbExpr: EditorContextKeys.Focus,
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_L
}
});
}
}
export class CompatChangeAll extends AbstractSelectHighlightsAction {
constructor() {
super(
'editor.action.changeAll',
nls.localize('changeAll.label', "Change All Occurrences"),
'Change All Occurrences'
);
this._precondition = null;
this.kbOpts = {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.CtrlCmd | KeyCode.F2
};
this.menuOpts = {
group: '1_modification',
order: 1.2,
kbExpr: EditorContextKeys.Writable
};
super({
id: 'editor.action.changeAll',
label: nls.localize('changeAll.label', "Change All Occurrences"),
alias: 'Change All Occurrences',
precondition: null,
kbOpts: {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.CtrlCmd | KeyCode.F2
},
menuOpts: {
group: '1_modification',
order: 1.2,
kbExpr: EditorContextKeys.Writable
}
});
}
}
@ -902,76 +853,85 @@ CommonEditorRegistry.registerEditorAction(new MoveSelectionToPreviousFindMatchAc
CommonEditorRegistry.registerEditorAction(new AddSelectionToNextFindMatchAction());
CommonEditorRegistry.registerEditorAction(new AddSelectionToPreviousFindMatchAction());
const FindCommand = EditorCommand.bindToContribution<CommonFindController>(
CommonFindController.getFindController, {
weight: CommonEditorRegistry.commandWeight(5),
kbExpr: EditorContextKeys.Focus
}
);
const FindCommand = EditorCommand.bindToContribution<CommonFindController>(CommonFindController.getFindController);
const VisibleWidgetFindCommand = EditorCommand.bindToContribution(
CommonFindController.getFindController, {
CommonEditorRegistry.registerEditorCommand2(new FindCommand({
id: FIND_IDS.CloseFindWidgetCommand,
precondition: CONTEXT_FIND_WIDGET_VISIBLE,
handler: x => x.closeFindWidget(),
kbOpts: {
weight: CommonEditorRegistry.commandWeight(5),
kbExpr: KbExpr.and(EditorContextKeys.Focus, CONTEXT_FIND_WIDGET_VISIBLE)
}
);
CommonEditorRegistry.registerEditorCommand2(new VisibleWidgetFindCommand(
FIND_IDS.CloseFindWidgetCommand,
x => x.closeFindWidget(),
{
kbExpr: EditorContextKeys.Focus,
primary: KeyCode.Escape,
secondary: [KeyMod.Shift | KeyCode.Escape]
}
));
}));
CommonEditorRegistry.registerEditorCommand2(new FindCommand(
FIND_IDS.ToggleCaseSensitiveCommand,
x => x.toggleCaseSensitive(),
{
CommonEditorRegistry.registerEditorCommand2(new FindCommand({
id: FIND_IDS.ToggleCaseSensitiveCommand,
precondition: null,
handler: x => x.toggleCaseSensitive(),
kbOpts: {
weight: CommonEditorRegistry.commandWeight(5),
kbExpr: EditorContextKeys.Focus,
primary: KeyMod.Alt | KeyCode.KEY_C,
mac: { primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.KEY_C }
}
));
}));
CommonEditorRegistry.registerEditorCommand2(new FindCommand(
FIND_IDS.ToggleWholeWordCommand,
x => x.toggleWholeWords(),
{
CommonEditorRegistry.registerEditorCommand2(new FindCommand({
id: FIND_IDS.ToggleWholeWordCommand,
precondition: null,
handler: x => x.toggleWholeWords(),
kbOpts: {
weight: CommonEditorRegistry.commandWeight(5),
kbExpr: EditorContextKeys.Focus,
primary: KeyMod.Alt | KeyCode.KEY_W,
mac: { primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.KEY_W }
}
));
}));
CommonEditorRegistry.registerEditorCommand2(new FindCommand(
FIND_IDS.ToggleRegexCommand,
x => x.toggleRegex(),
{
CommonEditorRegistry.registerEditorCommand2(new FindCommand({
id: FIND_IDS.ToggleRegexCommand,
precondition: null,
handler: x => x.toggleRegex(),
kbOpts: {
weight: CommonEditorRegistry.commandWeight(5),
kbExpr: EditorContextKeys.Focus,
primary: KeyMod.Alt | KeyCode.KEY_R,
mac: { primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.KEY_R }
}
));
}));
CommonEditorRegistry.registerEditorCommand2(new VisibleWidgetFindCommand(
FIND_IDS.ReplaceOneAction,
x => x.replace(),
{
CommonEditorRegistry.registerEditorCommand2(new FindCommand({
id: FIND_IDS.ReplaceOneAction,
precondition: CONTEXT_FIND_WIDGET_VISIBLE,
handler: x => x.replace(),
kbOpts: {
weight: CommonEditorRegistry.commandWeight(5),
kbExpr: EditorContextKeys.Focus,
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_1
}
));
}));
CommonEditorRegistry.registerEditorCommand2(new VisibleWidgetFindCommand(
FIND_IDS.ReplaceAllAction,
x => x.replaceAll(),
{
CommonEditorRegistry.registerEditorCommand2(new FindCommand({
id: FIND_IDS.ReplaceAllAction,
precondition: CONTEXT_FIND_WIDGET_VISIBLE,
handler: x => x.replaceAll(),
kbOpts: {
weight: CommonEditorRegistry.commandWeight(5),
kbExpr: EditorContextKeys.Focus,
primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.Enter
}
));
}));
CommonEditorRegistry.registerEditorCommand2(new VisibleWidgetFindCommand(
FIND_IDS.SelectAllMatchesAction,
x => x.selectAllMatches(),
{
CommonEditorRegistry.registerEditorCommand2(new FindCommand({
id: FIND_IDS.SelectAllMatchesAction,
precondition: CONTEXT_FIND_WIDGET_VISIBLE,
handler: x => x.selectAllMatches(),
kbOpts: {
weight: CommonEditorRegistry.commandWeight(5),
kbExpr: EditorContextKeys.Focus,
primary: KeyMod.Alt | KeyCode.Enter
}
));
}));

View file

@ -648,18 +648,7 @@ export class FoldingController implements editorCommon.IEditorContribution {
}
}
abstract class FoldingAction2 extends EditorAction {
constructor(id:string, label:string, alias:string, keybinding:number) {
super(id, label, alias, false);
this._precondition = null;
this.kbOpts = {
kbExpr: EditorContextKeys.TextFocus,
primary: keybinding
};
}
abstract class FoldingAction extends EditorAction {
abstract invoke(foldingController: FoldingController, editor:editorCommon.ICommonCodeEditor): void;
@ -669,15 +658,19 @@ abstract class FoldingAction2 extends EditorAction {
}
}
class UnfoldAction extends FoldingAction2 {
class UnfoldAction extends FoldingAction {
constructor() {
super(
'editor.unfold',
nls.localize('unfoldAction.label', "Unfold"),
'Unfold',
KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.US_CLOSE_SQUARE_BRACKET
);
super({
id: 'editor.unfold',
label: nls.localize('unfoldAction.label', "Unfold"),
alias: 'Unfold',
precondition: null,
kbOpts: {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.US_CLOSE_SQUARE_BRACKET
}
});
}
invoke(foldingController: FoldingController, editor:editorCommon.ICommonCodeEditor): void {
@ -685,15 +678,19 @@ class UnfoldAction extends FoldingAction2 {
}
}
class UnFoldRecursivelyAction extends FoldingAction2 {
class UnFoldRecursivelyAction extends FoldingAction {
constructor() {
super(
'editor.unFoldRecursively',
nls.localize('unFoldRecursivelyAction.label', "Unfold Recursively"),
'Unfold Recursively',
KeyMod.chord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.US_CLOSE_SQUARE_BRACKET)
);
super({
id: 'editor.unFoldRecursively',
label: nls.localize('unFoldRecursivelyAction.label', "Unfold Recursively"),
alias: 'Unfold Recursively',
precondition: null,
kbOpts: {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.chord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.US_CLOSE_SQUARE_BRACKET)
}
});
}
invoke(foldingController: FoldingController, editor:editorCommon.ICommonCodeEditor): void {
@ -701,15 +698,19 @@ class UnFoldRecursivelyAction extends FoldingAction2 {
}
}
class FoldAction extends FoldingAction2 {
class FoldAction extends FoldingAction {
constructor() {
super(
'editor.fold',
nls.localize('foldAction.label', "Fold"),
'Fold',
KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.US_OPEN_SQUARE_BRACKET
);
super({
id: 'editor.fold',
label: nls.localize('foldAction.label', "Fold"),
alias: 'Fold',
precondition: null,
kbOpts: {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.US_OPEN_SQUARE_BRACKET
}
});
}
invoke(foldingController: FoldingController, editor:editorCommon.ICommonCodeEditor): void {
@ -717,15 +718,19 @@ class FoldAction extends FoldingAction2 {
}
}
class FoldRecursivelyAction extends FoldingAction2 {
class FoldRecursivelyAction extends FoldingAction {
constructor() {
super(
'editor.foldRecursively',
nls.localize('foldRecursivelyAction.label', "Fold Recursively"),
'Fold Recursively',
KeyMod.chord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.US_OPEN_SQUARE_BRACKET)
);
super({
id: 'editor.foldRecursively',
label: nls.localize('foldRecursivelyAction.label', "Fold Recursively"),
alias: 'Fold Recursively',
precondition: null,
kbOpts: {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.chord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.US_OPEN_SQUARE_BRACKET)
}
});
}
invoke(foldingController: FoldingController, editor:editorCommon.ICommonCodeEditor): void {
@ -733,15 +738,19 @@ class FoldRecursivelyAction extends FoldingAction2 {
}
}
class FoldAllAction extends FoldingAction2 {
class FoldAllAction extends FoldingAction {
constructor() {
super(
'editor.foldAll',
nls.localize('foldAllAction.label', "Fold All"),
'Fold All',
KeyMod.chord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_0)
);
super({
id: 'editor.foldAll',
label: nls.localize('foldAllAction.label', "Fold All"),
alias: 'Fold All',
precondition: null,
kbOpts: {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.chord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_0)
}
});
}
invoke(foldingController: FoldingController, editor:editorCommon.ICommonCodeEditor): void {
@ -749,15 +758,19 @@ class FoldAllAction extends FoldingAction2 {
}
}
class UnfoldAllAction extends FoldingAction2 {
class UnfoldAllAction extends FoldingAction {
constructor() {
super(
'editor.unfoldAll',
nls.localize('unfoldAllAction.label', "Unfold All"),
'Unfold All',
KeyMod.chord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_J)
);
super({
id: 'editor.unfoldAll',
label: nls.localize('unfoldAllAction.label', "Unfold All"),
alias: 'Unfold All',
precondition: null,
kbOpts: {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.chord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_J)
}
});
}
invoke(foldingController: FoldingController, editor:editorCommon.ICommonCodeEditor): void {
@ -765,14 +778,10 @@ class UnfoldAllAction extends FoldingAction2 {
}
}
class FoldLevelAction extends FoldingAction2 {
class FoldLevelAction extends FoldingAction {
private static ID_PREFIX = 'editor.foldLevel';
public static ID = (level:number) => FoldLevelAction.ID_PREFIX + level;
constructor(id:string, label:string, alias:string, keybinding:number) {
super(id, label, alias, keybinding);
}
private getFoldingLevel() {
return parseInt(this.id.substr(FoldLevelAction.ID_PREFIX.length));
}
@ -795,42 +804,62 @@ CommonEditorRegistry.registerEditorAction(new FoldRecursivelyAction());
CommonEditorRegistry.registerEditorAction(new FoldAllAction());
CommonEditorRegistry.registerEditorAction(new UnfoldAllAction());
CommonEditorRegistry.registerEditorAction(
new FoldLevelAction(
FoldLevelAction.ID(1),
nls.localize('foldLevel1Action.label', "Fold Level 1"),
'Fold Level 1',
KeyMod.chord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_1)
)
new FoldLevelAction({
id: FoldLevelAction.ID(1),
label: nls.localize('foldLevel1Action.label', "Fold Level 1"),
alias: 'Fold Level 1',
precondition: null,
kbOpts: {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.chord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_1)
}
})
);
CommonEditorRegistry.registerEditorAction(
new FoldLevelAction(
FoldLevelAction.ID(2),
nls.localize('foldLevel2Action.label', "Fold Level 2"),
'Fold Level 2',
KeyMod.chord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_2)
)
new FoldLevelAction({
id: FoldLevelAction.ID(2),
label: nls.localize('foldLevel2Action.label', "Fold Level 2"),
alias: 'Fold Level 2',
precondition: null,
kbOpts: {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.chord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_2)
}
})
);
CommonEditorRegistry.registerEditorAction(
new FoldLevelAction(
FoldLevelAction.ID(3),
nls.localize('foldLevel3Action.label', "Fold Level 3"),
'Fold Level 3',
KeyMod.chord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_3)
)
new FoldLevelAction({
id: FoldLevelAction.ID(3),
label: nls.localize('foldLevel3Action.label', "Fold Level 3"),
alias: 'Fold Level 3',
precondition: null,
kbOpts: {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.chord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_3)
}
})
);
CommonEditorRegistry.registerEditorAction(
new FoldLevelAction(
FoldLevelAction.ID(4),
nls.localize('foldLevel4Action.label', "Fold Level 4"),
'Fold Level 4',
KeyMod.chord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_4)
)
new FoldLevelAction({
id: FoldLevelAction.ID(4),
label: nls.localize('foldLevel4Action.label', "Fold Level 4"),
alias: 'Fold Level 4',
precondition: null,
kbOpts: {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.chord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_4)
}
})
);
CommonEditorRegistry.registerEditorAction(
new FoldLevelAction(
FoldLevelAction.ID(5),
nls.localize('foldLevel5Action.label', "Fold Level 5"),
'Fold Level 5',
KeyMod.chord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_5)
)
new FoldLevelAction({
id: FoldLevelAction.ID(5),
label: nls.localize('foldLevel5Action.label', "Fold Level 5"),
alias: 'Fold Level 5',
precondition: null,
kbOpts: {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.chord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_5)
}
})
);

View file

@ -138,26 +138,22 @@ class FormatOnType implements editorCommon.IEditorContribution {
export class FormatAction extends EditorAction {
constructor() {
super(
'editor.action.format',
nls.localize('formatAction.label', "Format Code"),
'Format Code',
true
);
this._precondition = KbExpr.and(EditorContextKeys.Writable, ModeContextKeys.hasFormattingProvider);
this.kbOpts = {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.Shift | KeyMod.Alt | KeyCode.KEY_F,
linux: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_I }
};
this.menuOpts = {
group: '1_modification',
order: 1.3,
kbExpr: ModeContextKeys.hasFormattingProvider
};
super({
id: 'editor.action.format',
label: nls.localize('formatAction.label', "Format Code"),
alias: 'Format Code',
precondition: KbExpr.and(EditorContextKeys.Writable, ModeContextKeys.hasFormattingProvider),
kbOpts: {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.Shift | KeyMod.Alt | KeyCode.KEY_F,
linux: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_I }
},
menuOpts: {
group: '1_modification',
order: 1.3,
kbExpr: ModeContextKeys.hasFormattingProvider
}
});
}
public run(accessor:ServicesAccessor, editor:editorCommon.ICommonCodeEditor): TPromise<void> {

View file

@ -21,7 +21,7 @@ import {IEditorService} from 'vs/platform/editor/common/editor';
import {IMessageService} from 'vs/platform/message/common/message';
import {Range} from 'vs/editor/common/core/range';
import * as editorCommon from 'vs/editor/common/editorCommon';
import {ServicesAccessor, EditorAction, CommonEditorRegistry} from 'vs/editor/common/editorCommonExtensions';
import {IActionOptions, ServicesAccessor, EditorAction, CommonEditorRegistry} from 'vs/editor/common/editorCommonExtensions';
import {Location, DefinitionProviderRegistry} from 'vs/editor/common/modes';
import {ICodeEditor, IEditorMouseEvent, IMouseTarget} from 'vs/editor/browser/editorBrowser';
import {EditorBrowserRegistry} from 'vs/editor/browser/editorBrowserExtensions';
@ -50,8 +50,8 @@ export class DefinitionAction extends EditorAction {
private _configuration: DefinitionActionConfig;
constructor(id: string, label: string, alias: string, configuration: DefinitionActionConfig) {
super(id, label, alias, false);
constructor(configuration: DefinitionActionConfig, opts:IActionOptions) {
super(opts);
this._configuration = configuration;
}
@ -151,25 +151,21 @@ export class GoToDefinitionAction extends DefinitionAction {
public static ID = 'editor.action.goToDeclaration';
constructor() {
super(
GoToDefinitionAction.ID,
nls.localize('actions.goToDecl.label', "Go to Definition"),
'Go to Definition',
new DefinitionActionConfig()
);
this._precondition = ModeContextKeys.hasDefinitionProvider;
this.kbOpts = {
kbExpr: EditorContextKeys.TextFocus,
primary: goToDeclarationKb
};
this.menuOpts = {
group: 'navigation',
order: 1.1,
kbExpr: ModeContextKeys.hasDefinitionProvider
};
super(new DefinitionActionConfig(), {
id: GoToDefinitionAction.ID,
label: nls.localize('actions.goToDecl.label', "Go to Definition"),
alias: 'Go to Definition',
precondition: ModeContextKeys.hasDefinitionProvider,
kbOpts: {
kbExpr: EditorContextKeys.TextFocus,
primary: goToDeclarationKb
},
menuOpts: {
group: 'navigation',
order: 1.1,
kbExpr: ModeContextKeys.hasDefinitionProvider
}
});
}
}
@ -178,44 +174,37 @@ export class OpenDefinitionToSideAction extends DefinitionAction {
public static ID = 'editor.action.openDeclarationToTheSide';
constructor() {
super(
OpenDefinitionToSideAction.ID,
nls.localize('actions.goToDeclToSide.label', "Open Definition to the Side"),
'Open Definition to the Side',
new DefinitionActionConfig(true)
);
this._precondition = ModeContextKeys.hasDefinitionProvider;
this.kbOpts = {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.chord(KeyMod.CtrlCmd | KeyCode.KEY_K, goToDeclarationKb)
};
super(new DefinitionActionConfig(true), {
id: OpenDefinitionToSideAction.ID,
label: nls.localize('actions.goToDeclToSide.label', "Open Definition to the Side"),
alias: 'Open Definition to the Side',
precondition: ModeContextKeys.hasDefinitionProvider,
kbOpts: {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.chord(KeyMod.CtrlCmd | KeyCode.KEY_K, goToDeclarationKb)
}
});
}
}
export class PeekDefinitionAction extends DefinitionAction {
constructor() {
super(
'editor.action.previewDeclaration',
nls.localize('actions.previewDecl.label', "Peek Definition"),
'Peek Definition',
new DefinitionActionConfig(void 0, true, false)
);
this._precondition = KbExpr.and(ModeContextKeys.hasDefinitionProvider, PeekContext.notInPeekEditor);
this.kbOpts = {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.Alt | KeyCode.F12,
linux: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.F10 }
};
this.menuOpts = {
group: 'navigation',
order: 1.2,
kbExpr: ModeContextKeys.hasDefinitionProvider
};
super(new DefinitionActionConfig(void 0, true, false), {
id: 'editor.action.previewDeclaration',
label: nls.localize('actions.previewDecl.label', "Peek Definition"),
alias: 'Peek Definition',
precondition: KbExpr.and(ModeContextKeys.hasDefinitionProvider, PeekContext.notInPeekEditor),
kbOpts: {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.Alt | KeyCode.F12,
linux: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.F10 }
},
menuOpts: {
group: 'navigation',
order: 1.2,
kbExpr: ModeContextKeys.hasDefinitionProvider
}
});
}
}

View file

@ -17,13 +17,13 @@ import {TPromise} from 'vs/base/common/winjs.base';
import * as dom from 'vs/base/browser/dom';
import {renderHtml} from 'vs/base/browser/htmlContentRenderer';
import {ICommandService} from 'vs/platform/commands/common/commands';
import {KbExpr, KbCtxKey, IKeybindingContextKey, IKeybindingService} from 'vs/platform/keybinding/common/keybinding';
import {KbCtxKey, IKeybindingContextKey, IKeybindingService} from 'vs/platform/keybinding/common/keybinding';
import {IMarker, IMarkerService} from 'vs/platform/markers/common/markers';
import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry';
import {Position} from 'vs/editor/common/core/position';
import {Range} from 'vs/editor/common/core/range';
import * as editorCommon from 'vs/editor/common/editorCommon';
import {ServicesAccessor, EditorAction, EditorCommand, CommonEditorRegistry} from 'vs/editor/common/editorCommonExtensions';
import {ServicesAccessor, IActionOptions, EditorAction, EditorCommand, CommonEditorRegistry} from 'vs/editor/common/editorCommonExtensions';
import {ICodeEditor} from 'vs/editor/browser/editorBrowser';
import {EditorBrowserRegistry} from 'vs/editor/browser/editorBrowserExtensions';
import {ZoneWidget} from 'vs/editor/contrib/zoneWidget/browser/zoneWidget';
@ -412,8 +412,8 @@ class MarkerNavigationAction extends EditorAction {
private _isNext: boolean;
constructor(id:string, label:string, alias:string, next: boolean) {
super(id, label, alias, true);
constructor(next: boolean, opts:IActionOptions) {
super(opts);
this._isNext = next;
}
@ -514,60 +514,52 @@ class MarkerController implements editorCommon.IEditorContribution {
class NextMarkerAction extends MarkerNavigationAction {
constructor() {
super(
'editor.action.marker.next',
nls.localize('markerAction.next.label', "Go to Next Error or Warning"),
'Go to Next Error or Warning',
true
);
this._precondition = EditorContextKeys.Writable;
this.kbOpts = {
kbExpr: EditorContextKeys.Focus,
primary: KeyCode.F8
};
super(true, {
id: 'editor.action.marker.next',
label: nls.localize('markerAction.next.label', "Go to Next Error or Warning"),
alias: 'Go to Next Error or Warning',
precondition: EditorContextKeys.Writable,
kbOpts: {
kbExpr: EditorContextKeys.Focus,
primary: KeyCode.F8
}
});
}
}
class PrevMarkerAction extends MarkerNavigationAction {
constructor() {
super(
'editor.action.marker.prev',
nls.localize('markerAction.previous.label', "Go to Previous Error or Warning"),
'Go to Previous Error or Warning',
false
);
this._precondition = EditorContextKeys.Writable;
this.kbOpts = {
kbExpr: EditorContextKeys.Focus,
primary: KeyMod.Shift | KeyCode.F8
};
super(false, {
id: 'editor.action.marker.prev',
label: nls.localize('markerAction.previous.label', "Go to Previous Error or Warning"),
alias: 'Go to Previous Error or Warning',
precondition: EditorContextKeys.Writable,
kbOpts: {
kbExpr: EditorContextKeys.Focus,
primary: KeyMod.Shift | KeyCode.F8
}
});
}
}
var CONTEXT_MARKERS_NAVIGATION_VISIBLE = new KbCtxKey<boolean>('markersNavigationVisible', false);
const MarkerCommand = EditorCommand.bindToContribution<MarkerController>(
MarkerController.getMarkerController, {
weight: CommonEditorRegistry.commandWeight(50),
kbExpr: KbExpr.and(EditorContextKeys.Focus, CONTEXT_MARKERS_NAVIGATION_VISIBLE)
}
);
const MarkerCommand = EditorCommand.bindToContribution<MarkerController>(MarkerController.getMarkerController);
// register actions
CommonEditorRegistry.registerEditorAction(new NextMarkerAction());
CommonEditorRegistry.registerEditorAction(new PrevMarkerAction());
CommonEditorRegistry.registerEditorCommand2(new MarkerCommand(
'closeMarkersNavigation',
x => x.closeMarkersNavigation(),
{
CommonEditorRegistry.registerEditorCommand2(new MarkerCommand({
id: 'closeMarkersNavigation',
precondition: CONTEXT_MARKERS_NAVIGATION_VISIBLE,
handler: x => x.closeMarkersNavigation(),
kbOpts: {
weight: CommonEditorRegistry.commandWeight(50),
kbExpr: EditorContextKeys.Focus,
primary: KeyCode.Escape,
secondary: [KeyMod.Shift | KeyCode.Escape]
}
));
}));
EditorBrowserRegistry.registerEditorContribution(MarkerController);

View file

@ -146,19 +146,16 @@ class ModesHoverController implements editorCommon.IEditorContribution {
class ShowHoverAction extends EditorAction {
constructor() {
super(
'editor.action.showHover',
nls.localize('showHover', "Show Hover"),
'Show Hover',
false
);
this._precondition = null;
this.kbOpts = {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.chord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_I)
};
super({
id: 'editor.action.showHover',
label: nls.localize('showHover', "Show Hover"),
alias: 'Show Hover',
precondition: null,
kbOpts: {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.chord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_I)
}
});
}
public run(accessor:ServicesAccessor, editor:editorCommon.ICommonCodeEditor): void {

View file

@ -128,19 +128,16 @@ class InPlaceReplaceController implements IEditorContribution {
class InPlaceReplaceUp extends EditorAction {
constructor() {
super(
'editor.action.inPlaceReplace.up',
nls.localize('InPlaceReplaceAction.previous.label', "Replace with Previous Value"),
'Replace with Previous Value',
true
);
this._precondition = EditorContextKeys.Writable;
this.kbOpts = {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.US_COMMA
};
super({
id: 'editor.action.inPlaceReplace.up',
label: nls.localize('InPlaceReplaceAction.previous.label', "Replace with Previous Value"),
alias: 'Replace with Previous Value',
precondition: EditorContextKeys.Writable,
kbOpts: {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.US_COMMA
}
});
}
public run(accessor:ServicesAccessor, editor:ICommonCodeEditor): TPromise<void> {
@ -151,19 +148,16 @@ class InPlaceReplaceUp extends EditorAction {
class InPlaceReplaceDown extends EditorAction {
constructor() {
super(
'editor.action.inPlaceReplace.down',
nls.localize('InPlaceReplaceAction.next.label', "Replace with Next Value"),
'Replace with Next Value',
true
);
this._precondition = EditorContextKeys.Writable;
this.kbOpts = {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.US_DOT
};
super({
id: 'editor.action.inPlaceReplace.down',
label: nls.localize('InPlaceReplaceAction.next.label', "Replace with Next Value"),
alias: 'Replace with Next Value',
precondition: EditorContextKeys.Writable,
kbOpts: {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.US_DOT
}
});
}
public run(accessor:ServicesAccessor, editor:ICommonCodeEditor): TPromise<void> {

View file

@ -6,7 +6,7 @@
import * as nls from 'vs/nls';
import {TPromise} from 'vs/base/common/winjs.base';
import {ICommonCodeEditor, EditorContextKeys} from 'vs/editor/common/editorCommon';
import {ServicesAccessor, EditorAction, CommonEditorRegistry} from 'vs/editor/common/editorCommonExtensions';
import {ServicesAccessor, IActionOptions, EditorAction, CommonEditorRegistry} from 'vs/editor/common/editorCommonExtensions';
import {IndentationToSpacesCommand, IndentationToTabsCommand} from 'vs/editor/contrib/indentation/common/indentationCommands';
import {IQuickOpenService} from 'vs/workbench/services/quickopen/common/quickOpenService';
import {IModelService} from 'vs/editor/common/services/modelService';
@ -15,14 +15,12 @@ export class IndentationToSpacesAction extends EditorAction {
public static ID = 'editor.action.indentationToSpaces';
constructor() {
super(
IndentationToSpacesAction.ID,
nls.localize('indentationToSpaces', "Convert Indentation to Spaces"),
'Convert Indentation to Spaces',
true
);
this._precondition = EditorContextKeys.Writable;
super({
id: IndentationToSpacesAction.ID,
label: nls.localize('indentationToSpaces', "Convert Indentation to Spaces"),
alias: 'Convert Indentation to Spaces',
precondition: EditorContextKeys.Writable
});
}
public run(accessor:ServicesAccessor, editor:ICommonCodeEditor): void {
@ -43,14 +41,12 @@ export class IndentationToTabsAction extends EditorAction {
public static ID = 'editor.action.indentationToTabs';
constructor() {
super(
IndentationToTabsAction.ID,
nls.localize('indentationToTabs', "Convert Indentation to Tabs"),
'Convert Indentation to Tabs',
true
);
this._precondition = EditorContextKeys.Writable;
super({
id: IndentationToTabsAction.ID,
label: nls.localize('indentationToTabs', "Convert Indentation to Tabs"),
alias: 'Convert Indentation to Tabs',
precondition: EditorContextKeys.Writable
});
}
public run(accessor:ServicesAccessor, editor:ICommonCodeEditor): void {
@ -69,10 +65,8 @@ export class IndentationToTabsAction extends EditorAction {
export class ChangeIndentationSizeAction extends EditorAction {
constructor(id: string, label: string, alias: string, private insertSpaces: boolean) {
super(id, label, alias, false);
this._precondition = null;
constructor(private insertSpaces: boolean, opts: IActionOptions) {
super(opts);
}
public run(accessor:ServicesAccessor, editor:ICommonCodeEditor): TPromise<void> {
@ -113,14 +107,12 @@ export class IndentUsingTabs extends ChangeIndentationSizeAction {
public static ID = 'editor.action.indentUsingTabs';
constructor() {
super(
IndentUsingTabs.ID,
nls.localize('indentUsingTabs', "Indent Using Tabs"),
'Indent Using Tabs',
false
);
this._precondition = null;
super(false, {
id: IndentUsingTabs.ID,
label: nls.localize('indentUsingTabs', "Indent Using Tabs"),
alias: 'Indent Using Tabs',
precondition: null
});
}
}
@ -129,14 +121,12 @@ export class IndentUsingSpaces extends ChangeIndentationSizeAction {
public static ID = 'editor.action.indentUsingSpaces';
constructor() {
super(
IndentUsingSpaces.ID,
nls.localize('indentUsingSpaces', "Indent Using Spaces"),
'Indent Using Spaces',
true
);
this._precondition = null;
super(true, {
id: IndentUsingSpaces.ID,
label: nls.localize('indentUsingSpaces', "Indent Using Spaces"),
alias: 'Indent Using Spaces',
precondition: null
});
}
}
@ -145,14 +135,12 @@ export class DetectIndentation extends EditorAction {
public static ID = 'editor.action.detectIndentation';
constructor() {
super(
DetectIndentation.ID,
nls.localize('detectIndentation', "Detect Indentation from Content"),
'Detect Indentation from Content',
false
);
this._precondition = null;
super({
id: DetectIndentation.ID,
label: nls.localize('detectIndentation', "Detect Indentation from Content"),
alias: 'Detect Indentation from Content',
precondition: null
});
}
public run(accessor:ServicesAccessor, editor:ICommonCodeEditor): void {
@ -171,14 +159,12 @@ export class DetectIndentation extends EditorAction {
export class ToggleRenderWhitespaceAction extends EditorAction {
constructor() {
super(
'editor.action.toggleRenderWhitespace',
nls.localize('toggleRenderWhitespace', "Toggle Render Whitespace"),
'Toggle Render Whitespace',
false
);
this._precondition = null;
super({
id: 'editor.action.toggleRenderWhitespace',
label: nls.localize('toggleRenderWhitespace', "Toggle Render Whitespace"),
alias: 'Toggle Render Whitespace',
precondition: null
});
}
public run(accessor:ServicesAccessor, editor:ICommonCodeEditor): void {
@ -191,14 +177,12 @@ export class ToggleRenderWhitespaceAction extends EditorAction {
export class ToggleRenderControlCharacterAction extends EditorAction {
constructor() {
super(
'editor.action.toggleRenderControlCharacter',
nls.localize('toggleRenderControlCharacters', "Toggle Control Characters"),
'Toggle Render Control Characters',
false
);
this._precondition = null;
super({
id: 'editor.action.toggleRenderControlCharacter',
label: nls.localize('toggleRenderControlCharacters', "Toggle Control Characters"),
alias: 'Toggle Render Control Characters',
precondition: null
});
}
public run(accessor:ServicesAccessor, editor:ICommonCodeEditor): void {

View file

@ -9,7 +9,7 @@ import {KeyCode, KeyMod} from 'vs/base/common/keyCodes';
import {SortLinesCommand} from 'vs/editor/contrib/linesOperations/common/sortLinesCommand';
import {TrimTrailingWhitespaceCommand} from 'vs/editor/common/commands/trimTrailingWhitespaceCommand';
import {EditorContextKeys, Handler, ICommand, ICommonCodeEditor} from 'vs/editor/common/editorCommon';
import {ServicesAccessor, EditorAction, HandlerEditorAction, CommonEditorRegistry} from 'vs/editor/common/editorCommonExtensions';
import {ServicesAccessor, IActionOptions, EditorAction, HandlerEditorAction, CommonEditorRegistry} from 'vs/editor/common/editorCommonExtensions';
import {CopyLinesCommand} from './copyLinesCommand';
import {DeleteLinesCommand} from './deleteLinesCommand';
import {MoveLinesCommand} from './moveLinesCommand';
@ -20,8 +20,8 @@ abstract class AbstractCopyLinesAction extends EditorAction {
private down:boolean;
constructor(id:string, label:string, alias:string, down:boolean) {
super(id, label, alias, true);
constructor(down:boolean, opts:IActionOptions) {
super(opts);
this.down = down;
}
@ -40,39 +40,33 @@ abstract class AbstractCopyLinesAction extends EditorAction {
class CopyLinesUpAction extends AbstractCopyLinesAction {
constructor() {
super(
'editor.action.copyLinesUpAction',
nls.localize('lines.copyUp', "Copy Line Up"),
'Copy Line Up',
false
);
this._precondition = EditorContextKeys.Writable;
this.kbOpts = {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.Alt | KeyMod.Shift | KeyCode.UpArrow,
linux: { primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyMod.Shift | KeyCode.UpArrow }
};
super(false, {
id: 'editor.action.copyLinesUpAction',
label: nls.localize('lines.copyUp', "Copy Line Up"),
alias: 'Copy Line Up',
precondition: EditorContextKeys.Writable,
kbOpts: {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.Alt | KeyMod.Shift | KeyCode.UpArrow,
linux: { primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyMod.Shift | KeyCode.UpArrow }
}
});
}
}
class CopyLinesDownAction extends AbstractCopyLinesAction {
constructor() {
super(
'editor.action.copyLinesDownAction',
nls.localize('lines.copyDown', "Copy Line Down"),
'Copy Line Down',
true
);
this._precondition = EditorContextKeys.Writable;
this.kbOpts = {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.Alt | KeyMod.Shift | KeyCode.DownArrow,
linux: { primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyMod.Shift | KeyCode.DownArrow }
};
super(true, {
id: 'editor.action.copyLinesDownAction',
label: nls.localize('lines.copyDown', "Copy Line Down"),
alias: 'Copy Line Down',
precondition: EditorContextKeys.Writable,
kbOpts: {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.Alt | KeyMod.Shift | KeyCode.DownArrow,
linux: { primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyMod.Shift | KeyCode.DownArrow }
}
});
}
}
@ -82,8 +76,8 @@ abstract class AbstractMoveLinesAction extends EditorAction {
private down:boolean;
constructor(id:string, label:string, alias:string, down:boolean) {
super(id, label, alias, true);
constructor(down:boolean, opts:IActionOptions) {
super(opts);
this.down = down;
}
@ -102,47 +96,41 @@ abstract class AbstractMoveLinesAction extends EditorAction {
class MoveLinesUpAction extends AbstractMoveLinesAction {
constructor() {
super(
'editor.action.moveLinesUpAction',
nls.localize('lines.moveUp', "Move Line Up"),
'Move Line Up',
false
);
this._precondition = EditorContextKeys.Writable;
this.kbOpts = {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.Alt | KeyCode.UpArrow,
linux: { primary: KeyMod.Alt | KeyCode.UpArrow }
};
super(false, {
id: 'editor.action.moveLinesUpAction',
label: nls.localize('lines.moveUp', "Move Line Up"),
alias: 'Move Line Up',
precondition: EditorContextKeys.Writable,
kbOpts: {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.Alt | KeyCode.UpArrow,
linux: { primary: KeyMod.Alt | KeyCode.UpArrow }
}
});
}
}
class MoveLinesDownAction extends AbstractMoveLinesAction {
constructor() {
super(
'editor.action.moveLinesDownAction',
nls.localize('lines.moveDown', "Move Line Down"),
'Move Line Down',
true
);
this._precondition = EditorContextKeys.Writable;
this.kbOpts = {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.Alt | KeyCode.DownArrow,
linux: { primary: KeyMod.Alt | KeyCode.DownArrow }
};
super(true, {
id: 'editor.action.moveLinesDownAction',
label: nls.localize('lines.moveDown', "Move Line Down"),
alias: 'Move Line Down',
precondition: EditorContextKeys.Writable,
kbOpts: {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.Alt | KeyCode.DownArrow,
linux: { primary: KeyMod.Alt | KeyCode.DownArrow }
}
});
}
}
abstract class AbstractSortLinesAction extends EditorAction {
private descending:boolean;
constructor(id:string, label:string, alias:string, descending:boolean) {
super(id, label, alias, true);
constructor(descending:boolean, opts:IActionOptions) {
super(opts);
this.descending = descending;
}
@ -160,37 +148,31 @@ abstract class AbstractSortLinesAction extends EditorAction {
class SortLinesAscendingAction extends AbstractSortLinesAction {
constructor() {
super(
'editor.action.sortLinesAscending',
nls.localize('lines.sortAscending', "Sort Lines Ascending"),
'Sort Lines Ascending',
false
);
this._precondition = EditorContextKeys.Writable;
this.kbOpts = {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_2
};
super(false, {
id: 'editor.action.sortLinesAscending',
label: nls.localize('lines.sortAscending', "Sort Lines Ascending"),
alias: 'Sort Lines Ascending',
precondition: EditorContextKeys.Writable,
kbOpts: {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_2
}
});
}
}
class SortLinesDescendingAction extends AbstractSortLinesAction {
constructor() {
super(
'editor.action.sortLinesDescending',
nls.localize('lines.sortDescending', "Sort Lines Descending"),
'Sort Lines Descending',
true
);
this._precondition = EditorContextKeys.Writable;
this.kbOpts = {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_3
};
super(true, {
id: 'editor.action.sortLinesDescending',
label: nls.localize('lines.sortDescending', "Sort Lines Descending"),
alias: 'Sort Lines Descending',
precondition: EditorContextKeys.Writable,
kbOpts: {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_3
}
});
}
}
@ -199,19 +181,16 @@ export class TrimTrailingWhitespaceAction extends EditorAction {
public static ID = 'editor.action.trimTrailingWhitespace';
constructor() {
super(
TrimTrailingWhitespaceAction.ID,
nls.localize('lines.trimTrailingWhitespace', "Trim Trailing Whitespace"),
'Trim Trailing Whitespace',
true
);
this._precondition = EditorContextKeys.Writable;
this.kbOpts = {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.chord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_X)
};
super({
id: TrimTrailingWhitespaceAction.ID,
label: nls.localize('lines.trimTrailingWhitespace', "Trim Trailing Whitespace"),
alias: 'Trim Trailing Whitespace',
precondition: EditorContextKeys.Writable,
kbOpts: {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.chord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_X)
}
});
}
public run(accessor:ServicesAccessor, editor:ICommonCodeEditor): void {
@ -231,11 +210,6 @@ interface IDeleteLinesOperation {
}
abstract class AbstractRemoveLinesAction extends EditorAction {
constructor(id:string, label:string, alias:string) {
super(id, label, alias, true);
}
_getLinesToRemove(editor:ICommonCodeEditor): IDeleteLinesOperation[] {
// Construct delete operations
var operations:IDeleteLinesOperation[] = editor.getSelections().map((s) => {
@ -275,24 +249,21 @@ abstract class AbstractRemoveLinesAction extends EditorAction {
return mergedOperations;
}
}
class DeleteLinesAction extends AbstractRemoveLinesAction {
constructor() {
super(
'editor.action.deleteLines',
nls.localize('lines.delete', "Delete Line"),
'Delete Line'
);
this._precondition = EditorContextKeys.Writable;
this.kbOpts = {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_K
};
super({
id: 'editor.action.deleteLines',
label: nls.localize('lines.delete', "Delete Line"),
alias: 'Delete Line',
precondition: EditorContextKeys.Writable,
kbOpts: {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_K
}
});
}
public run(accessor:ServicesAccessor, editor:ICommonCodeEditor): void {
@ -310,77 +281,65 @@ class DeleteLinesAction extends AbstractRemoveLinesAction {
class IndentLinesAction extends HandlerEditorAction {
constructor() {
super(
'editor.action.indentLines',
nls.localize('lines.indent', "Indent Line"),
'Indent Line',
true,
Handler.Indent
);
this._precondition = EditorContextKeys.Writable;
this.kbOpts = {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.CtrlCmd | KeyCode.US_CLOSE_SQUARE_BRACKET
};
super({
id: 'editor.action.indentLines',
label: nls.localize('lines.indent', "Indent Line"),
alias: 'Indent Line',
precondition: EditorContextKeys.Writable,
handlerId: Handler.Indent,
kbOpts: {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.CtrlCmd | KeyCode.US_CLOSE_SQUARE_BRACKET
}
});
}
}
class OutdentLinesAction extends HandlerEditorAction {
constructor() {
super(
'editor.action.outdentLines',
nls.localize('lines.outdent', "Outdent Line"),
'Outdent Line',
true,
Handler.Outdent
);
this._precondition = EditorContextKeys.Writable;
this.kbOpts = {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.CtrlCmd | KeyCode.US_OPEN_SQUARE_BRACKET
};
super({
id: 'editor.action.outdentLines',
label: nls.localize('lines.outdent', "Outdent Line"),
alias: 'Outdent Line',
precondition: EditorContextKeys.Writable,
handlerId: Handler.Outdent,
kbOpts: {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.CtrlCmd | KeyCode.US_OPEN_SQUARE_BRACKET
}
});
}
}
class InsertLineBeforeAction extends HandlerEditorAction {
constructor() {
super(
'editor.action.insertLineBefore',
nls.localize('lines.insertBefore', "Insert Line Above"),
'Insert Line Above',
true,
Handler.LineInsertBefore
);
this._precondition = EditorContextKeys.Writable;
this.kbOpts = {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.Enter
};
super({
id: 'editor.action.insertLineBefore',
label: nls.localize('lines.insertBefore', "Insert Line Above"),
alias: 'Insert Line Above',
precondition: EditorContextKeys.Writable,
handlerId: Handler.LineInsertBefore,
kbOpts: {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.Enter
}
});
}
}
class InsertLineAfterAction extends HandlerEditorAction {
constructor() {
super(
'editor.action.insertLineAfter',
nls.localize('lines.insertAfter', "Insert Line Below"),
'Insert Line Below',
true,
Handler.LineInsertAfter
);
this._precondition = EditorContextKeys.Writable;
this.kbOpts = {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.CtrlCmd | KeyCode.Enter
};
super({
id: 'editor.action.insertLineAfter',
label: nls.localize('lines.insertAfter', "Insert Line Below"),
alias: 'Insert Line Below',
precondition: EditorContextKeys.Writable,
handlerId: Handler.LineInsertAfter,
kbOpts: {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.CtrlCmd | KeyCode.Enter
}
});
}
}

View file

@ -318,14 +318,12 @@ class LinkDetector implements editorCommon.IEditorContribution {
class OpenLinkAction extends EditorAction {
constructor() {
super(
'editor.action.openLink',
nls.localize('label', "Open Link"),
'Open Link',
false
);
this._precondition = null;
super({
id: 'editor.action.openLink',
label: nls.localize('label', "Open Link"),
alias: 'Open Link',
precondition: null
});
}
public run(accessor:ServicesAccessor, editor:editorCommon.ICommonCodeEditor): void {

View file

@ -11,66 +11,57 @@ import {ServicesAccessor, EditorAction, HandlerEditorAction, CommonEditorRegistr
class InsertCursorAbove extends HandlerEditorAction {
constructor() {
super(
'editor.action.insertCursorAbove',
nls.localize('mutlicursor.insertAbove', "Add Cursor Above"),
'Add Cursor Above',
false,
Handler.AddCursorUp
);
this._precondition = null;
this.kbOpts = {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.UpArrow,
linux: {
primary: KeyMod.Shift | KeyMod.Alt | KeyCode.UpArrow,
secondary: [KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.UpArrow]
super({
id: 'editor.action.insertCursorAbove',
label: nls.localize('mutlicursor.insertAbove', "Add Cursor Above"),
alias: 'Add Cursor Above',
precondition: null,
handlerId: Handler.AddCursorUp,
kbOpts: {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.UpArrow,
linux: {
primary: KeyMod.Shift | KeyMod.Alt | KeyCode.UpArrow,
secondary: [KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.UpArrow]
}
}
};
});
}
}
class InsertCursorBelow extends HandlerEditorAction {
constructor() {
super(
'editor.action.insertCursorBelow',
nls.localize('mutlicursor.insertBelow', "Add Cursor Below"),
'Add Cursor Below',
false,
Handler.AddCursorDown
);
this._precondition = null;
this.kbOpts = {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.DownArrow,
linux: {
primary: KeyMod.Shift | KeyMod.Alt | KeyCode.DownArrow,
secondary: [KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.DownArrow]
super({
id: 'editor.action.insertCursorBelow',
label: nls.localize('mutlicursor.insertBelow', "Add Cursor Below"),
alias: 'Add Cursor Below',
precondition: null,
handlerId: Handler.AddCursorDown,
kbOpts: {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.DownArrow,
linux: {
primary: KeyMod.Shift | KeyMod.Alt | KeyCode.DownArrow,
secondary: [KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.DownArrow]
}
}
};
});
}
}
class InsertCursorAtEndOfEachLineSelected extends EditorAction {
constructor() {
super(
'editor.action.insertCursorAtEndOfEachLineSelected',
nls.localize('mutlicursor.insertAtEndOfEachLineSelected', "Create Multiple Cursors from Selected Lines"),
'Create Multiple Cursors from Selected Lines',
false
);
this._precondition = null;
this.kbOpts = {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.Shift | KeyMod.Alt | KeyCode.KEY_I
};
super({
id: 'editor.action.insertCursorAtEndOfEachLineSelected',
label: nls.localize('mutlicursor.insertAtEndOfEachLineSelected', "Create Multiple Cursors from Selected Lines"),
alias: 'Create Multiple Cursors from Selected Lines',
precondition: null,
kbOpts: {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.Shift | KeyMod.Alt | KeyCode.KEY_I
}
});
}
public run(accessor:ServicesAccessor, editor:ICommonCodeEditor): void {

View file

@ -60,19 +60,16 @@ class ParameterHintsController implements IEditorContribution {
export class TriggerParameterHintsAction extends EditorAction {
constructor() {
super(
'editor.action.triggerParameterHints',
nls.localize('parameterHints.trigger.label', "Trigger Parameter Hints"),
'Trigger Parameter Hints',
false
);
this._precondition = ModeContextKeys.hasSignatureHelpProvider;
this.kbOpts = {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.Space
};
super({
id: 'editor.action.triggerParameterHints',
label: nls.localize('parameterHints.trigger.label', "Trigger Parameter Hints"),
alias: 'Trigger Parameter Hints',
precondition: ModeContextKeys.hasSignatureHelpProvider,
kbOpts: {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.Space
}
});
}
public run(accessor:ServicesAccessor, editor:ICommonCodeEditor): void {
@ -82,47 +79,44 @@ export class TriggerParameterHintsAction extends EditorAction {
const weight = CommonEditorRegistry.commandWeight(75);
const ParameterHintsCommand = EditorCommand.bindToContribution(
ParameterHintsController.get, {
weight: weight,
kbExpr: KbExpr.and(EditorContextKeys.TextFocus, Context.Visible)
}
);
const MultipleSignaturesParameterHintsCommand = EditorCommand.bindToContribution(
ParameterHintsController.get, {
weight: weight,
kbExpr: KbExpr.and(EditorContextKeys.TextFocus, Context.Visible, Context.MultipleSignatures)
}
);
const ParameterHintsCommand = EditorCommand.bindToContribution<ParameterHintsController>(ParameterHintsController.get);
EditorBrowserRegistry.registerEditorContribution(ParameterHintsController);
CommonEditorRegistry.registerEditorAction(new TriggerParameterHintsAction());
CommonEditorRegistry.registerEditorCommand2(new ParameterHintsCommand(
'closeParameterHints',
x => x.cancel(),
{
CommonEditorRegistry.registerEditorCommand2(new ParameterHintsCommand({
id: 'closeParameterHints',
precondition: Context.Visible,
handler: x => x.cancel(),
kbOpts: {
weight: weight,
kbExpr: EditorContextKeys.TextFocus,
primary: KeyCode.Escape,
secondary: [KeyMod.Shift | KeyCode.Escape]
}
));
CommonEditorRegistry.registerEditorCommand2(new MultipleSignaturesParameterHintsCommand(
'showPrevParameterHint',
x => x.previous(),
{
}));
CommonEditorRegistry.registerEditorCommand2(new ParameterHintsCommand({
id: 'showPrevParameterHint',
precondition: KbExpr.and(Context.Visible, Context.MultipleSignatures),
handler: x => x.previous(),
kbOpts: {
weight: weight,
kbExpr: EditorContextKeys.TextFocus,
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(),
{
}));
CommonEditorRegistry.registerEditorCommand2(new ParameterHintsCommand({
id: 'showNextParameterHint',
precondition: KbExpr.and(Context.Visible, Context.MultipleSignatures),
handler: x => x.next(),
kbOpts: {
weight: weight,
kbExpr: EditorContextKeys.TextFocus,
primary: KeyCode.DownArrow,
secondary: [KeyMod.Alt | KeyCode.DownArrow],
mac: { primary: KeyCode.DownArrow, secondary: [KeyMod.Alt | KeyCode.DownArrow, KeyMod.WinCtrl | KeyCode.KEY_N] }
}
));
}));

View file

@ -117,19 +117,16 @@ export class QuickFixController implements IEditorContribution {
export class QuickFixAction extends EditorAction {
constructor() {
super(
'editor.action.quickFix',
nls.localize('quickfix.trigger.label', "Quick Fix"),
'Quick Fix',
true
);
this._precondition = KbExpr.and(EditorContextKeys.Writable, ModeContextKeys.hasCodeActionsProvider);
this.kbOpts = {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.CtrlCmd | KeyCode.US_DOT
};
super({
id: 'editor.action.quickFix',
label: nls.localize('quickfix.trigger.label', "Quick Fix"),
alias: 'Quick Fix',
precondition: KbExpr.and(EditorContextKeys.Writable, ModeContextKeys.hasCodeActionsProvider),
kbOpts: {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.CtrlCmd | KeyCode.US_DOT
}
});
}
public run(accessor:ServicesAccessor, editor:ICommonCodeEditor): void {
@ -139,60 +136,73 @@ export class QuickFixAction extends EditorAction {
var CONTEXT_QUICK_FIX_WIDGET_VISIBLE = new KbCtxKey<boolean>('quickFixWidgetVisible', false);
const QuickFixCommand = EditorCommand.bindToContribution<QuickFixController>(
QuickFixController.getQuickFixController, {
weight: CommonEditorRegistry.commandWeight(80),
kbExpr: KbExpr.and(EditorContextKeys.Focus, CONTEXT_QUICK_FIX_WIDGET_VISIBLE)
}
);
const QuickFixCommand = EditorCommand.bindToContribution<QuickFixController>(QuickFixController.getQuickFixController);
// register action
CommonEditorRegistry.registerEditorAction(new QuickFixAction());
CommonEditorRegistry.registerEditorCommand2(new QuickFixCommand(
'acceptQuickFixSuggestion',
x => x.acceptSelectedSuggestion(),
{
CommonEditorRegistry.registerEditorCommand2(new QuickFixCommand({
id: 'acceptQuickFixSuggestion',
precondition: CONTEXT_QUICK_FIX_WIDGET_VISIBLE,
handler: x => x.acceptSelectedSuggestion(),
kbOpts: {
weight: CommonEditorRegistry.commandWeight(80),
kbExpr: EditorContextKeys.Focus,
primary: KeyCode.Enter,
secondary: [KeyCode.Tab]
}
));
CommonEditorRegistry.registerEditorCommand2(new QuickFixCommand(
'closeQuickFixWidget',
x => x.closeWidget(),
{
}));
CommonEditorRegistry.registerEditorCommand2(new QuickFixCommand({
id: 'closeQuickFixWidget',
precondition: CONTEXT_QUICK_FIX_WIDGET_VISIBLE,
handler: x => x.closeWidget(),
kbOpts: {
weight: CommonEditorRegistry.commandWeight(80),
kbExpr: EditorContextKeys.Focus,
primary: KeyCode.Escape,
secondary: [KeyMod.Shift | KeyCode.Escape]
}
));
CommonEditorRegistry.registerEditorCommand2(new QuickFixCommand(
'selectNextQuickFix',
x => x.selectNextSuggestion(),
{
}));
CommonEditorRegistry.registerEditorCommand2(new QuickFixCommand({
id: 'selectNextQuickFix',
precondition: CONTEXT_QUICK_FIX_WIDGET_VISIBLE,
handler: x => x.selectNextSuggestion(),
kbOpts: {
weight: CommonEditorRegistry.commandWeight(80),
kbExpr: EditorContextKeys.Focus,
primary: KeyCode.DownArrow,
mac: { primary: KeyCode.DownArrow, secondary: [KeyMod.WinCtrl | KeyCode.KEY_N] }
}
));
CommonEditorRegistry.registerEditorCommand2(new QuickFixCommand(
'selectNextPageQuickFix',
x => x.selectNextPageSuggestion(),
{
}));
CommonEditorRegistry.registerEditorCommand2(new QuickFixCommand({
id: 'selectNextPageQuickFix',
precondition: CONTEXT_QUICK_FIX_WIDGET_VISIBLE,
handler: x => x.selectNextPageSuggestion(),
kbOpts: {
weight: CommonEditorRegistry.commandWeight(80),
kbExpr: EditorContextKeys.Focus,
primary: KeyCode.PageDown
}
));
CommonEditorRegistry.registerEditorCommand2(new QuickFixCommand(
'selectPrevQuickFix',
x => x.selectPrevSuggestion(),
{
}));
CommonEditorRegistry.registerEditorCommand2(new QuickFixCommand({
id: 'selectPrevQuickFix',
precondition: CONTEXT_QUICK_FIX_WIDGET_VISIBLE,
handler: x => x.selectPrevSuggestion(),
kbOpts: {
weight: CommonEditorRegistry.commandWeight(80),
kbExpr: EditorContextKeys.Focus,
primary: KeyCode.UpArrow,
mac: { primary: KeyCode.UpArrow, secondary: [KeyMod.WinCtrl | KeyCode.KEY_P] }
}
));
CommonEditorRegistry.registerEditorCommand2(new QuickFixCommand(
'selectPrevPageQuickFix',
x => x.selectPrevPageSuggestion(),
{
}));
CommonEditorRegistry.registerEditorCommand2(new QuickFixCommand({
id: 'selectPrevPageQuickFix',
precondition: CONTEXT_QUICK_FIX_WIDGET_VISIBLE,
handler: x => x.selectPrevPageSuggestion(),
kbOpts: {
weight: CommonEditorRegistry.commandWeight(80),
kbExpr: EditorContextKeys.Focus,
primary: KeyCode.PageUp
}
));
}));
EditorBrowserRegistry.registerEditorContribution(QuickFixController);

View file

@ -11,7 +11,7 @@ import {ICodeEditor} from 'vs/editor/browser/editorBrowser';
import {EditorBrowserRegistry} from 'vs/editor/browser/editorBrowserExtensions';
import {QuickOpenEditorWidget} from './quickOpenEditorWidget';
import {Selection} from 'vs/editor/common/core/selection';
import {EditorAction} from 'vs/editor/common/editorCommonExtensions';
import {IActionOptions, EditorAction} from 'vs/editor/common/editorCommonExtensions';
export interface IQuickOpenControllerOpts {
inputAriaLabel: string;
@ -142,8 +142,8 @@ export abstract class BaseEditorQuickOpenAction extends EditorAction {
private _inputAriaLabel:string;
constructor(id:string, label:string, alias:string, inputAriaLabel:string) {
super(id, label, alias, false);
constructor(inputAriaLabel:string, opts:IActionOptions) {
super(opts);
this._inputAriaLabel = inputAriaLabel;
}

View file

@ -152,20 +152,17 @@ export class GotoLineEntry extends QuickOpenEntry {
export class GotoLineAction extends BaseEditorQuickOpenAction {
constructor() {
super(
'editor.action.gotoLine',
nls.localize('GotoLineAction.label', "Go to Line..."),
'Go to Line...',
nls.localize('gotoLineActionInput', "Type a line number, followed by an optional colon and a column number to navigate to")
);
this._precondition = null;
this.kbOpts = {
kbExpr: EditorContextKeys.Focus,
primary: KeyMod.CtrlCmd | KeyCode.KEY_G,
mac: { primary: KeyMod.WinCtrl | KeyCode.KEY_G }
};
super(nls.localize('gotoLineActionInput', "Type a line number, followed by an optional colon and a column number to navigate to"), {
id: 'editor.action.gotoLine',
label: nls.localize('GotoLineAction.label', "Go to Line..."),
alias: 'Go to Line...',
precondition: null,
kbOpts: {
kbExpr: EditorContextKeys.Focus,
primary: KeyMod.CtrlCmd | KeyCode.KEY_G,
mac: { primary: KeyMod.WinCtrl | KeyCode.KEY_G }
}
});
}
public run(accessor:ServicesAccessor, editor:editorCommon.ICommonCodeEditor): void {

View file

@ -72,23 +72,19 @@ export class EditorActionCommandEntry extends QuickOpenEntryGroup {
export class QuickCommandAction extends BaseEditorQuickOpenAction {
constructor() {
super(
'editor.action.quickCommand',
nls.localize('QuickCommandAction.label', "Command Palette"),
'Command Palette',
nls.localize('quickCommandActionInput', "Type the name of an action you want to execute")
);
this._precondition = null;
this.kbOpts = {
kbExpr: EditorContextKeys.Focus,
primary: (browser.isIE11orEarlier ? KeyMod.Alt | KeyCode.F1 : KeyCode.F1)
};
this.menuOpts = {
kbExpr: EditorContextKeys.Focus
};
super(nls.localize('quickCommandActionInput', "Type the name of an action you want to execute"), {
id: 'editor.action.quickCommand',
label: nls.localize('QuickCommandAction.label', "Command Palette"),
alias: 'Command Palette',
precondition: null,
kbOpts: {
kbExpr: EditorContextKeys.Focus,
primary: (browser.isIE11orEarlier ? KeyMod.Alt | KeyCode.F1 : KeyCode.F1)
},
menuOpts: {
kbExpr: EditorContextKeys.Focus
}
});
}
public run(accessor:ServicesAccessor, editor:ICommonCodeEditor): void {

View file

@ -110,25 +110,21 @@ class SymbolEntry extends QuickOpenEntryGroup {
export class QuickOutlineAction extends BaseEditorQuickOpenAction {
constructor() {
super(
'editor.action.quickOutline',
nls.localize('QuickOutlineAction.label', "Go to Symbol..."),
'Go to Symbol...',
nls.localize('quickOutlineActionInput', "Type the name of an identifier you wish to navigate to")
);
this._precondition = ModeContextKeys.hasDocumentSymbolProvider;
this.kbOpts = {
kbExpr: EditorContextKeys.Focus,
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_O
};
this.menuOpts = {
group: 'navigation',
order: 3,
kbExpr: ModeContextKeys.hasDocumentSymbolProvider
};
super(nls.localize('quickOutlineActionInput', "Type the name of an identifier you wish to navigate to"), {
id: 'editor.action.quickOutline',
label: nls.localize('QuickOutlineAction.label', "Go to Symbol..."),
alias: 'Go to Symbol...',
precondition: ModeContextKeys.hasDocumentSymbolProvider,
kbOpts: {
kbExpr: EditorContextKeys.Focus,
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_O
},
menuOpts: {
group: 'navigation',
order: 3,
kbExpr: ModeContextKeys.hasDocumentSymbolProvider
}
});
}
public run(accessor:ServicesAccessor, editor:ICommonCodeEditor): TPromise<void> {

View file

@ -57,25 +57,21 @@ export class ReferenceController implements editorCommon.IEditorContribution {
export class ReferenceAction extends EditorAction {
constructor() {
super(
'editor.action.referenceSearch.trigger',
nls.localize('references.action.label', "Find All References"),
'Find All References',
false
);
this._precondition = KbExpr.and(ModeContextKeys.hasReferenceProvider, PeekContext.notInPeekEditor);
this.kbOpts = {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.Shift | KeyCode.F12
};
this.menuOpts = {
kbExpr: ModeContextKeys.hasReferenceProvider,
group: 'navigation',
order: 1.3
};
super({
id: 'editor.action.referenceSearch.trigger',
label: nls.localize('references.action.label', "Find All References"),
alias: 'Find All References',
precondition: KbExpr.and(ModeContextKeys.hasReferenceProvider, PeekContext.notInPeekEditor),
kbOpts: {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.Shift | KeyCode.F12
},
menuOpts: {
kbExpr: ModeContextKeys.hasReferenceProvider,
group: 'navigation',
order: 1.3
}
});
}
public run(accessor:ServicesAccessor, editor:editorCommon.ICommonCodeEditor): void {

View file

@ -148,25 +148,21 @@ class RenameController implements IEditorContribution {
export class RenameAction extends EditorAction {
constructor() {
super(
'editor.action.rename',
nls.localize('rename.label', "Rename Symbol"),
'Rename Symbol',
true
);
this._precondition = KbExpr.and(EditorContextKeys.Writable, ModeContextKeys.hasRenameProvider);
this.kbOpts = {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyCode.F2
};
this.menuOpts = {
group: '1_modification',
order: 1.1,
kbExpr: KbExpr.and(ModeContextKeys.hasRenameProvider, EditorContextKeys.Writable)
};
super({
id: 'editor.action.rename',
label: nls.localize('rename.label', "Rename Symbol"),
alias: 'Rename Symbol',
precondition: KbExpr.and(EditorContextKeys.Writable, ModeContextKeys.hasRenameProvider),
kbOpts: {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyCode.F2
},
menuOpts: {
group: '1_modification',
order: 1.1,
kbExpr: KbExpr.and(ModeContextKeys.hasRenameProvider, EditorContextKeys.Writable)
}
});
}
public run(accessor:ServicesAccessor, editor:ICommonCodeEditor): TPromise<void> {
@ -176,28 +172,29 @@ export class RenameAction extends EditorAction {
EditorBrowserRegistry.registerEditorContribution(RenameController);
const RenameCommand = EditorCommand.bindToContribution<RenameController>(
RenameController.get, {
weight: CommonEditorRegistry.commandWeight(99),
kbExpr: KbExpr.and(EditorContextKeys.Focus, CONTEXT_RENAME_INPUT_VISIBLE)
}
);
const RenameCommand = EditorCommand.bindToContribution<RenameController>(RenameController.get);
CommonEditorRegistry.registerEditorAction(new RenameAction());
CommonEditorRegistry.registerEditorCommand2(new RenameCommand(
'acceptRenameInput',
x => x.acceptRenameInput(),
{
CommonEditorRegistry.registerEditorCommand2(new RenameCommand({
id: 'acceptRenameInput',
precondition: CONTEXT_RENAME_INPUT_VISIBLE,
handler: x => x.acceptRenameInput(),
kbOpts: {
weight: CommonEditorRegistry.commandWeight(99),
kbExpr: EditorContextKeys.Focus,
primary: KeyCode.Enter
}
));
}));
CommonEditorRegistry.registerEditorCommand2(new RenameCommand(
'cancelRenameInput',
x => x.cancelRenameInput(),
{
CommonEditorRegistry.registerEditorCommand2(new RenameCommand({
id: 'cancelRenameInput',
precondition: CONTEXT_RENAME_INPUT_VISIBLE,
handler: x => x.cancelRenameInput(),
kbOpts: {
weight: CommonEditorRegistry.commandWeight(99),
kbExpr: EditorContextKeys.Focus,
primary: KeyCode.Escape,
secondary: [KeyMod.Shift | KeyCode.Escape]
}
));
}));

View file

@ -10,22 +10,18 @@ import {Handler, EditorContextKeys} from 'vs/editor/common/editorCommon';
import {HandlerEditorAction, CommonEditorRegistry} from 'vs/editor/common/editorCommonExtensions';
class SelectBracketAction extends HandlerEditorAction {
constructor() {
super(
'editor.action.jumpToBracket',
nls.localize('smartSelect.jumpBracket', "Go to Bracket"),
'Go to Bracket',
false,
Handler.JumpToBracket
);
this._precondition = null;
this.kbOpts = {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.US_BACKSLASH
};
super({
id: 'editor.action.jumpToBracket',
label: nls.localize('smartSelect.jumpBracket', "Go to Bracket"),
alias: 'Go to Bracket',
precondition: null,
handlerId: Handler.JumpToBracket,
kbOpts: {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.US_BACKSLASH
}
});
}
}

View file

@ -11,7 +11,7 @@ import {TPromise} from 'vs/base/common/winjs.base';
import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation';
import {Range} from 'vs/editor/common/core/range';
import {ICommonCodeEditor, ICursorPositionChangedEvent, EditorContextKeys, IEditorContribution} from 'vs/editor/common/editorCommon';
import {ServicesAccessor, EditorAction, CommonEditorRegistry} from 'vs/editor/common/editorCommonExtensions';
import {ServicesAccessor, IActionOptions, EditorAction, CommonEditorRegistry} from 'vs/editor/common/editorCommonExtensions';
import {TokenSelectionSupport, ILogicalSelectionEntry} from './tokenSelectionSupport';
// --- selection state machine
@ -146,8 +146,8 @@ abstract class AbstractSmartSelect extends EditorAction {
private _forward: boolean;
constructor(id:string, label:string, alias:string, forward: boolean) {
super(id, label, alias, false);
constructor(forward: boolean, opts:IActionOptions) {
super(opts);
this._forward = forward;
}
@ -158,39 +158,33 @@ abstract class AbstractSmartSelect extends EditorAction {
class GrowSelectionAction extends AbstractSmartSelect {
constructor() {
super(
'editor.action.smartSelect.grow',
nls.localize('smartSelect.grow', "Expand Select"),
'Expand Select',
true
);
this._precondition = null;
this.kbOpts = {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.Shift | KeyMod.Alt | KeyCode.RightArrow,
mac: { primary: KeyMod.CtrlCmd | KeyMod.WinCtrl | KeyMod.Shift | KeyCode.RightArrow }
};
super(true, {
id: 'editor.action.smartSelect.grow',
label: nls.localize('smartSelect.grow', "Expand Select"),
alias: 'Expand Select',
precondition: null,
kbOpts: {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.Shift | KeyMod.Alt | KeyCode.RightArrow,
mac: { primary: KeyMod.CtrlCmd | KeyMod.WinCtrl | KeyMod.Shift | KeyCode.RightArrow }
}
});
}
}
class ShrinkSelectionAction extends AbstractSmartSelect {
constructor() {
super(
'editor.action.smartSelect.shrink',
nls.localize('smartSelect.shrink', "Shrink Select"),
'Shrink Select',
false
);
this._precondition = null;
this.kbOpts = {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.Shift | KeyMod.Alt | KeyCode.LeftArrow,
mac: { primary: KeyMod.CtrlCmd | KeyMod.WinCtrl | KeyMod.Shift | KeyCode.LeftArrow }
};
super(false, {
id: 'editor.action.smartSelect.shrink',
label: nls.localize('smartSelect.shrink', "Shrink Select"),
alias: 'Shrink Select',
precondition: null,
kbOpts: {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.Shift | KeyMod.Alt | KeyCode.LeftArrow,
mac: { primary: KeyMod.CtrlCmd | KeyMod.WinCtrl | KeyMod.Shift | KeyCode.LeftArrow }
}
});
}
}

View file

@ -8,7 +8,7 @@
import * as collections from 'vs/base/common/collections';
import {KeyCode, KeyMod} from 'vs/base/common/keyCodes';
import * as strings from 'vs/base/common/strings';
import {KbExpr, KbCtxKey, IKeybindingContextKey, IKeybindingService} from 'vs/platform/keybinding/common/keybinding';
import {KbCtxKey, IKeybindingContextKey, IKeybindingService} from 'vs/platform/keybinding/common/keybinding';
import {EditOperation} from 'vs/editor/common/core/editOperation';
import {Range} from 'vs/editor/common/core/range';
import {Selection} from 'vs/editor/common/core/selection';
@ -941,40 +941,47 @@ class SnippetController implements ISnippetController {
export var CONTEXT_SNIPPET_MODE = new KbCtxKey<boolean>('inSnippetMode', false);
const SnippetCommand = EditorCommand.bindToContribution<ISnippetController>(
SnippetController.get, {
weight: CommonEditorRegistry.commandWeight(30),
kbExpr: KbExpr.and(EditorContextKeys.TextFocus, CONTEXT_SNIPPET_MODE)
}
);
const SnippetCommand = EditorCommand.bindToContribution<ISnippetController>(SnippetController.get);
CommonEditorRegistry.registerEditorContribution(SnippetController);
CommonEditorRegistry.registerEditorCommand2(new SnippetCommand(
'jumpToNextSnippetPlaceholder',
x => x.jumpToNextPlaceholder(),
{
CommonEditorRegistry.registerEditorCommand2(new SnippetCommand({
id: 'jumpToNextSnippetPlaceholder',
precondition: CONTEXT_SNIPPET_MODE,
handler: x => x.jumpToNextPlaceholder(),
kbOpts: {
weight: CommonEditorRegistry.commandWeight(30),
kbExpr: EditorContextKeys.TextFocus,
primary: KeyCode.Tab
}
));
CommonEditorRegistry.registerEditorCommand2(new SnippetCommand(
'jumpToPrevSnippetPlaceholder',
x => x.jumpToPrevPlaceholder(),
{
}));
CommonEditorRegistry.registerEditorCommand2(new SnippetCommand({
id: 'jumpToPrevSnippetPlaceholder',
precondition: CONTEXT_SNIPPET_MODE,
handler: x => x.jumpToPrevPlaceholder(),
kbOpts: {
weight: CommonEditorRegistry.commandWeight(30),
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.Shift | KeyCode.Tab
}
));
CommonEditorRegistry.registerEditorCommand2(new SnippetCommand(
'acceptSnippet',
x => x.acceptSnippet(),
{
}));
CommonEditorRegistry.registerEditorCommand2(new SnippetCommand({
id: 'acceptSnippet',
precondition: CONTEXT_SNIPPET_MODE,
handler: x => x.acceptSnippet(),
kbOpts: {
weight: CommonEditorRegistry.commandWeight(30),
kbExpr: EditorContextKeys.TextFocus,
primary: KeyCode.Enter
}
));
CommonEditorRegistry.registerEditorCommand2(new SnippetCommand(
'leaveSnippet',
x => x.leaveSnippet(),
{
}));
CommonEditorRegistry.registerEditorCommand2(new SnippetCommand({
id: 'leaveSnippet',
precondition: CONTEXT_SNIPPET_MODE,
handler: x => x.leaveSnippet(),
kbOpts: {
weight: CommonEditorRegistry.commandWeight(30),
kbExpr: EditorContextKeys.TextFocus,
primary: KeyCode.Escape,
secondary: [KeyMod.Shift | KeyCode.Escape]
}
));
}));

View file

@ -170,20 +170,17 @@ export class SuggestController implements IEditorContribution {
export class TriggerSuggestAction extends EditorAction {
constructor() {
super(
'editor.action.triggerSuggest',
nls.localize('suggest.trigger.label', "Trigger Suggest"),
'Trigger Suggest',
true
);
this._precondition = KbExpr.and(EditorContextKeys.Writable, ModeContextKeys.hasCompletionItemProvider);
this.kbOpts = {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.CtrlCmd | KeyCode.Space,
mac: { primary: KeyMod.WinCtrl | KeyCode.Space }
};
super({
id: 'editor.action.triggerSuggest',
label: nls.localize('suggest.trigger.label', "Trigger Suggest"),
alias: 'Trigger Suggest',
precondition: KbExpr.and(EditorContextKeys.Writable, ModeContextKeys.hasCompletionItemProvider),
kbOpts: {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.CtrlCmd | KeyCode.Space,
mac: { primary: KeyMod.WinCtrl | KeyCode.Space }
}
});
}
public run(accessor:ServicesAccessor, editor:ICommonCodeEditor): void {
@ -195,95 +192,103 @@ CommonEditorRegistry.registerEditorAction(new TriggerSuggestAction());
const weight = CommonEditorRegistry.commandWeight(90);
const SuggestCommand = EditorCommand.bindToContribution(
SuggestController.getController, {
weight: weight,
kbExpr: KbExpr.and(EditorContextKeys.TextFocus, SuggestContext.Visible)
}
);
const MultipleSuggestionsCommand = EditorCommand.bindToContribution(
SuggestController.getController, {
weight: weight,
kbExpr: KbExpr.and(EditorContextKeys.TextFocus, SuggestContext.Visible, SuggestContext.MultipleSuggestions)
}
);
const AcceptSuggestionsOnEnterCommand = EditorCommand.bindToContribution(
SuggestController.getController, {
weight: weight,
kbExpr: KbExpr.and(EditorContextKeys.TextFocus, SuggestContext.Visible, KbExpr.has('config.editor.acceptSuggestionOnEnter'))
}
);
const SuggestCommand = EditorCommand.bindToContribution<SuggestController>(SuggestController.getController);
CommonEditorRegistry.registerEditorCommand2(new SuggestCommand(
'acceptSelectedSuggestion',
x => x.acceptSelectedSuggestion(),
{
CommonEditorRegistry.registerEditorCommand2(new SuggestCommand({
id: 'acceptSelectedSuggestion',
precondition: SuggestContext.Visible,
handler: x => x.acceptSelectedSuggestion(),
kbOpts: {
weight: weight,
kbExpr: EditorContextKeys.TextFocus,
primary: KeyCode.Tab
}
));
}));
CommonEditorRegistry.registerEditorCommand2(new AcceptSuggestionsOnEnterCommand(
'acceptSelectedSuggestionOnEnter',
x => x.acceptSelectedSuggestion(),
{
CommonEditorRegistry.registerEditorCommand2(new SuggestCommand({
id: 'acceptSelectedSuggestionOnEnter',
precondition: SuggestContext.Visible,
handler: x => x.acceptSelectedSuggestion(),
kbOpts: {
weight: weight,
kbExpr: KbExpr.and(EditorContextKeys.TextFocus, KbExpr.has('config.editor.acceptSuggestionOnEnter')),
primary: KeyCode.Enter
}
));
}));
CommonEditorRegistry.registerEditorCommand2(new SuggestCommand(
'hideSuggestWidget',
x => x.cancelSuggestWidget(),
{
CommonEditorRegistry.registerEditorCommand2(new SuggestCommand({
id: 'hideSuggestWidget',
precondition: SuggestContext.Visible,
handler: x => x.cancelSuggestWidget(),
kbOpts: {
weight: weight,
kbExpr: EditorContextKeys.TextFocus,
primary: KeyCode.Escape,
secondary: [KeyMod.Shift | KeyCode.Escape]
}
));
}));
CommonEditorRegistry.registerEditorCommand2(new MultipleSuggestionsCommand(
'selectNextSuggestion',
c => c.selectNextSuggestion(),
{
CommonEditorRegistry.registerEditorCommand2(new SuggestCommand({
id: 'selectNextSuggestion',
precondition: KbExpr.and(SuggestContext.Visible, SuggestContext.MultipleSuggestions),
handler: c => c.selectNextSuggestion(),
kbOpts: {
weight: weight,
kbExpr: EditorContextKeys.TextFocus,
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(
'selectNextPageSuggestion',
c => c.selectNextPageSuggestion(),
{
CommonEditorRegistry.registerEditorCommand2(new SuggestCommand({
id: 'selectNextPageSuggestion',
precondition: KbExpr.and(SuggestContext.Visible, SuggestContext.MultipleSuggestions),
handler: c => c.selectNextPageSuggestion(),
kbOpts: {
weight: weight,
kbExpr: EditorContextKeys.TextFocus,
primary: KeyCode.PageDown,
secondary: [KeyMod.Alt | KeyCode.PageDown]
}
));
}));
CommonEditorRegistry.registerEditorCommand2(new MultipleSuggestionsCommand(
'selectPrevSuggestion',
c => c.selectPrevSuggestion(),
{
CommonEditorRegistry.registerEditorCommand2(new SuggestCommand({
id: 'selectPrevSuggestion',
precondition: KbExpr.and(SuggestContext.Visible, SuggestContext.MultipleSuggestions),
handler: c => c.selectPrevSuggestion(),
kbOpts: {
weight: weight,
kbExpr: EditorContextKeys.TextFocus,
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(
'selectPrevPageSuggestion',
c => c.selectPrevPageSuggestion(),
{
CommonEditorRegistry.registerEditorCommand2(new SuggestCommand({
id: 'selectPrevPageSuggestion',
precondition: KbExpr.and(SuggestContext.Visible, SuggestContext.MultipleSuggestions),
handler: c => c.selectPrevPageSuggestion(),
kbOpts: {
weight: weight,
kbExpr: EditorContextKeys.TextFocus,
primary: KeyCode.PageUp,
secondary: [KeyMod.Alt | KeyCode.PageUp]
}
));
}));
CommonEditorRegistry.registerEditorCommand2(new SuggestCommand(
'toggleSuggestionDetails',
x => x.toggleSuggestionDetails(),
{
CommonEditorRegistry.registerEditorCommand2(new SuggestCommand({
id: 'toggleSuggestionDetails',
precondition: SuggestContext.Visible,
handler: x => x.toggleSuggestionDetails(),
kbOpts: {
weight: weight,
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.CtrlCmd | KeyCode.Space,
mac: { primary: KeyMod.WinCtrl | KeyCode.Space }
}
));
}));
EditorBrowserRegistry.registerEditorContribution(SuggestController);

View file

@ -21,9 +21,13 @@ let snippetsRegistry = <ISnippetsRegistry>Registry.as(Extensions.Snippets);
class TabCompletionController implements editorCommon.IEditorContribution {
static Id = 'editor.tabCompletionController';
private static ID = 'editor.tabCompletionController';
static ContextKey = new KbCtxKey<boolean>('hasSnippetCompletions', undefined);
public static get(editor:editorCommon.ICommonCodeEditor): TabCompletionController {
return <TabCompletionController>editor.getContribution(TabCompletionController.ID);
}
private _snippetController: ISnippetController;
private _cursorChangeSubscription: IDisposable;
private _currentSnippets: ISnippet[] = [];
@ -69,28 +73,25 @@ class TabCompletionController implements editorCommon.IEditorContribution {
}
getId(): string {
return TabCompletionController.Id;
return TabCompletionController.ID;
}
}
CommonEditorRegistry.registerEditorContribution(TabCompletionController);
const TabCompletionCommand = EditorCommand.bindToContribution<TabCompletionController>(
(editor) => <TabCompletionController>editor.getContribution(TabCompletionController.Id), {
const TabCompletionCommand = EditorCommand.bindToContribution<TabCompletionController>(TabCompletionController.get);
CommonEditorRegistry.registerEditorCommand2(new TabCompletionCommand({
id: 'insertSnippet',
precondition: TabCompletionController.ContextKey,
handler: x => x.performSnippetCompletions(),
kbOpts: {
weight: KeybindingsRegistry.WEIGHT.editorContrib(),
kbExpr: KbExpr.and(
TabCompletionController.ContextKey,
EditorContextKeys.TextFocus,
EditorContextKeys.TabDoesNotMoveFocus,
KbExpr.has('config.editor.tabCompletion')
)
}
);
CommonEditorRegistry.registerEditorCommand2(new TabCompletionCommand(
'insertSnippet',
x => x.performSnippetCompletions(),
{
),
primary: KeyCode.Tab
}
));
}));

View file

@ -20,14 +20,12 @@ interface ISnippetPick extends IPickOpenEntry {
class ShowSnippetsActions extends EditorAction {
constructor() {
super(
'editor.action.showSnippets',
nls.localize('snippet.suggestions.label', "Insert Snippet"),
'Insert Snippet',
true
);
this._precondition = EditorContextKeys.Writable;
super({
id: 'editor.action.showSnippets',
label: nls.localize('snippet.suggestions.label', "Insert Snippet"),
alias: 'Insert Snippet',
precondition: EditorContextKeys.Writable
});
}
public run(accessor:ServicesAccessor, editor:ICommonCodeEditor): TPromise<void> {

View file

@ -15,20 +15,17 @@ export class ToggleTabFocusModeAction extends EditorAction {
public static ID = 'editor.action.toggleTabFocusMode';
constructor() {
super(
ToggleTabFocusModeAction.ID,
nls.localize('toggle.tabfocusmode', "Toggle Use of Tab Key for Setting Focus"),
'Toggle Use of Tab Key for Setting Focus',
false
);
this._precondition = null;
this.kbOpts = {
kbExpr: null,
primary: KeyMod.CtrlCmd | KeyCode.KEY_M,
mac: { primary: KeyMod.WinCtrl | KeyMod.Shift | KeyCode.KEY_M }
};
super({
id: ToggleTabFocusModeAction.ID,
label: nls.localize('toggle.tabfocusmode', "Toggle Use of Tab Key for Setting Focus"),
alias: 'Toggle Use of Tab Key for Setting Focus',
precondition: null,
kbOpts: {
kbExpr: null,
primary: KeyMod.CtrlCmd | KeyCode.KEY_M,
mac: { primary: KeyMod.WinCtrl | KeyMod.Shift | KeyCode.KEY_M }
}
});
}
public run(accessor:ServicesAccessor, editor:ICommonCodeEditor): void {

View file

@ -12,19 +12,16 @@ import {ServicesAccessor, EditorAction, CommonEditorRegistry} from 'vs/editor/co
class ToggleWordWrapAction extends EditorAction {
constructor() {
super(
'editor.action.toggleWordWrap',
nls.localize('toggle.wordwrap', "View: Toggle Word Wrap"),
'View: Toggle Word Wrap',
false
);
this._precondition = null;
this.kbOpts = {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.Alt | KeyCode.KEY_Z
};
super({
id: 'editor.action.toggleWordWrap',
label: nls.localize('toggle.wordwrap', "View: Toggle Word Wrap"),
alias: 'View: Toggle Word Wrap',
precondition: null,
kbOpts: {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.Alt | KeyCode.KEY_Z
}
});
}
public run(accessor:ServicesAccessor, editor:ICommonCodeEditor): void {

View file

@ -18,7 +18,7 @@ import editorbrowser = require('vs/editor/browser/editorBrowser');
import {ZoneWidget} from 'vs/editor/contrib/zoneWidget/browser/zoneWidget';
import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation';
import {IContextViewService} from 'vs/platform/contextview/browser/contextView';
import {KbCtxKey, KbExpr, IKeybindingService, IKeybindingContextKey} from 'vs/platform/keybinding/common/keybinding';
import {KbCtxKey, IKeybindingService, IKeybindingContextKey} from 'vs/platform/keybinding/common/keybinding';
import debug = require('vs/workbench/parts/debug/common/debug');
import {IKeyboardEvent} from 'vs/base/browser/keyboardEvent';
@ -123,14 +123,16 @@ export class BreakpointWidget extends ZoneWidget {
class CloseBreakpointWidgetCommand extends EditorCommand {
constructor() {
super(CLOSE_BREAKPOINT_WIDGET_COMMAND_ID);
this.kbOpts = {
weight: CommonEditorRegistry.commandWeight(8),
kbExpr: KbExpr.and(EditorContextKeys.Focus, CONTEXT_BREAKPOINT_WIDGET_VISIBLE),
primary: KeyCode.Escape,
secondary: [KeyMod.Shift | KeyCode.Escape]
};
super({
id: CLOSE_BREAKPOINT_WIDGET_COMMAND_ID,
precondition: CONTEXT_BREAKPOINT_WIDGET_VISIBLE,
kbOpts: {
weight: CommonEditorRegistry.commandWeight(8),
kbExpr: EditorContextKeys.Focus,
primary: KeyCode.Escape,
secondary: [KeyMod.Shift | KeyCode.Escape]
}
});
}
protected runEditorCommand(accessor:ServicesAccessor, editor: ICommonCodeEditor, args: any): void {

View file

@ -520,19 +520,16 @@ export class EditConditionalBreakpointAction extends AbstractDebugAction {
export class ToggleBreakpointAction extends EditorAction {
constructor() {
super(
'editor.debug.action.toggleBreakpoint',
nls.localize('toggleBreakpointAction', "Debug: Toggle Breakpoint"),
'Debug: Toggle Breakpoint',
false
);
this._precondition = null;
this.kbOpts = {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyCode.F9
};
super({
id: 'editor.debug.action.toggleBreakpoint',
label: nls.localize('toggleBreakpointAction', "Debug: Toggle Breakpoint"),
alias: 'Debug: Toggle Breakpoint',
precondition: null,
kbOpts: {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyCode.F9
}
});
}
public run(accessor:ServicesAccessor, editor:editorCommon.ICommonCodeEditor): TPromise<void> {
@ -553,14 +550,12 @@ export class ToggleBreakpointAction extends EditorAction {
export class EditorConditionalBreakpointAction extends EditorAction {
constructor() {
super(
'editor.debug.action.conditionalBreakpoint',
nls.localize('conditionalBreakpointEditorAction', "Debug: Conditional Breakpoint"),
'Debug: Conditional Breakpoint',
false
);
this._precondition = null;
super({
id: 'editor.debug.action.conditionalBreakpoint',
label: nls.localize('conditionalBreakpointEditorAction', "Debug: Conditional Breakpoint"),
alias: 'Debug: Conditional Breakpoint',
precondition: null
});
}
public run(accessor:ServicesAccessor, editor:editorCommon.ICommonCodeEditor): void {
@ -599,19 +594,16 @@ export class SetValueAction extends AbstractDebugAction {
export class RunToCursorAction extends EditorAction {
constructor() {
super(
'editor.debug.action.runToCursor',
nls.localize('runToCursor', "Debug: Run to Cursor"),
'Debug: Run to Cursor',
false
);
this._precondition = debug.CONTEXT_IN_DEBUG_MODE;
this.menuOpts = {
kbExpr: debug.CONTEXT_IN_DEBUG_MODE,
group: 'debug'
};
super({
id: 'editor.debug.action.runToCursor',
label: nls.localize('runToCursor', "Debug: Run to Cursor"),
alias: 'Debug: Run to Cursor',
precondition: debug.CONTEXT_IN_DEBUG_MODE,
menuOpts: {
kbExpr: debug.CONTEXT_IN_DEBUG_MODE,
group: 'debug'
}
});
}
public run(accessor:ServicesAccessor, editor:editorCommon.ICommonCodeEditor): TPromise<void> {
@ -662,19 +654,16 @@ export class AddWatchExpressionAction extends AbstractDebugAction {
export class SelectionToReplAction extends EditorAction {
constructor() {
super(
'editor.debug.action.selectionToRepl',
nls.localize('debugEvaluate', "Debug: Evaluate"),
'Debug: Evaluate',
false
);
this._precondition = debug.CONTEXT_IN_DEBUG_MODE;
this.menuOpts = {
kbExpr: KbExpr.and(EditorContextKeys.HasNonEmptySelection, debug.CONTEXT_IN_DEBUG_MODE),
group: 'debug'
};
super({
id: 'editor.debug.action.selectionToRepl',
label: nls.localize('debugEvaluate', "Debug: Evaluate"),
alias: 'Debug: Evaluate',
precondition: debug.CONTEXT_IN_DEBUG_MODE,
menuOpts: {
kbExpr: KbExpr.and(EditorContextKeys.HasNonEmptySelection, debug.CONTEXT_IN_DEBUG_MODE),
group: 'debug'
}
});
}
public run(accessor:ServicesAccessor, editor:editorCommon.ICommonCodeEditor): TPromise<void> {
@ -692,19 +681,16 @@ export class SelectionToReplAction extends EditorAction {
export class ShowDebugHoverAction extends EditorAction {
constructor() {
super(
'editor.debug.action.showDebugHover',
nls.localize('showDebugHover', "Debug: Show Hover"),
'Debug: Show Hover',
false
);
this._precondition = debug.CONTEXT_IN_DEBUG_MODE;
this.kbOpts = {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.chord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_I)
};
super({
id: 'editor.debug.action.showDebugHover',
label: nls.localize('showDebugHover', "Debug: Show Hover"),
alias: 'Debug: Show Hover',
precondition: debug.CONTEXT_IN_DEBUG_MODE,
kbOpts: {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.chord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_I)
}
});
}
public run(accessor:ServicesAccessor, editor:editorCommon.ICommonCodeEditor): TPromise<void> {

View file

@ -15,6 +15,7 @@ import {EmmetEditorAction, EmmetActionContext} from 'vs/workbench/parts/emmet/no
import {Action} from 'vs/base/common/actions';
import {ServicesAccessor, CommonEditorRegistry} from 'vs/editor/common/editorCommonExtensions';
import {EditorContextKeys} from 'vs/editor/common/editorCommon';
import {IMessageService, Severity} from 'vs/platform/message/common/message';
import {IQuickOpenService, IInputOptions} from 'vs/workbench/services/quickopen/common/quickOpenService';
import {IWorkspaceContextService} from 'vs/workbench/services/workspace/common/contextService';
@ -24,11 +25,12 @@ class EncodeDecodeDataUrlAction extends EmmetEditorAction {
private imageFilePath: string = null;
constructor() {
super(
'editor.emmet.action.encodeDecodeDataUrl',
nls.localize('encodeDecodeDataUrl', "Emmet: Encode\\Decode data:URL image"),
'Emmet: Encode\\Decode data:URL image'
);
super({
id: 'editor.emmet.action.encodeDecodeDataUrl',
label: nls.localize('encodeDecodeDataUrl', "Emmet: Encode\\Decode data:URL image"),
alias: 'Emmet: Encode\\Decode data:URL image',
precondition: EditorContextKeys.Writable
});
}
private createPath(parent: string, fileName: string): string {

View file

@ -21,19 +21,18 @@ class ExpandAbbreviationAction extends BasicEmmetEditorAction {
'editor.emmet.action.expandAbbreviation',
nls.localize('expandAbbreviationAction', "Emmet: Expand Abbreviation"),
'Emmet: Expand Abbreviation',
'expand_abbreviation'
'expand_abbreviation',
{
primary: KeyCode.Tab,
kbExpr: KbExpr.and(
EditorContextKeys.TextFocus,
EditorContextKeys.HasOnlyEmptySelection,
EditorContextKeys.HasSingleSelection,
EditorContextKeys.TabDoesNotMoveFocus,
KbExpr.has('config.emmet.triggerExpansionOnTab')
)
}
);
this.kbOpts = {
primary: KeyCode.Tab,
kbExpr: KbExpr.and(
EditorContextKeys.TextFocus,
EditorContextKeys.HasOnlyEmptySelection,
EditorContextKeys.HasSingleSelection,
EditorContextKeys.TabDoesNotMoveFocus,
KbExpr.has('config.emmet.triggerExpansionOnTab')
)
};
}
protected noExpansionOccurred(editor:ICommonCodeEditor): void {

View file

@ -9,16 +9,18 @@ import nls = require('vs/nls');
import {EmmetEditorAction, EmmetActionContext} from 'vs/workbench/parts/emmet/node/emmetActions';
import {ServicesAccessor, CommonEditorRegistry} from 'vs/editor/common/editorCommonExtensions';
import {EditorContextKeys} from 'vs/editor/common/editorCommon';
import {IQuickOpenService, IInputOptions} from 'vs/workbench/services/quickopen/common/quickOpenService';
class UpdateTagAction extends EmmetEditorAction {
constructor() {
super(
'editor.emmet.action.updateTag',
nls.localize('updateTag', "Emmet: Update Tag"),
'Emmet: Update Tag'
);
super({
id: 'editor.emmet.action.updateTag',
label: nls.localize('updateTag', "Emmet: Update Tag"),
alias: 'Emmet: Update Tag',
precondition: EditorContextKeys.Writable
});
}
public runEmmetAction(accessor:ServicesAccessor, ctx: EmmetActionContext) {

View file

@ -9,16 +9,18 @@ import nls = require('vs/nls');
import {EmmetEditorAction, EmmetActionContext} from 'vs/workbench/parts/emmet/node/emmetActions';
import {ServicesAccessor, CommonEditorRegistry} from 'vs/editor/common/editorCommonExtensions';
import {EditorContextKeys} from 'vs/editor/common/editorCommon';
import {IQuickOpenService, IInputOptions} from 'vs/workbench/services/quickopen/common/quickOpenService';
class WrapWithAbbreviationAction extends EmmetEditorAction {
constructor() {
super(
'editor.emmet.action.wrapWithAbbreviation',
nls.localize('wrapWithAbbreviationAction', "Emmet: Wrap with Abbreviation"),
'Emmet: Wrap with Abbreviation'
);
super({
id: 'editor.emmet.action.wrapWithAbbreviation',
label: nls.localize('wrapWithAbbreviationAction', "Emmet: Wrap with Abbreviation"),
alias: 'Emmet: Wrap with Abbreviation',
precondition: EditorContextKeys.Writable
});
}
public runEmmetAction(accessor:ServicesAccessor, ctx: EmmetActionContext) {

View file

@ -8,6 +8,7 @@
import {TPromise} from 'vs/base/common/winjs.base';
import {ICommonCodeEditor, EditorContextKeys} from 'vs/editor/common/editorCommon';
import {EditorAction, ServicesAccessor} from 'vs/editor/common/editorCommonExtensions';
import {ICommandKeybindingsOptions} from 'vs/editor/common/config/config';
import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation';
import {EditorAccessor} from 'vs/workbench/parts/emmet/node/editorAccessor';
@ -99,13 +100,6 @@ export class EmmetActionContext {
export abstract class EmmetEditorAction extends EditorAction {
constructor(id:string, label:string, alias:string) {
super(id, label, alias, true);
this._precondition = EditorContextKeys.Writable;
}
abstract runEmmetAction(accessor:ServicesAccessor, ctx:EmmetActionContext);
protected noExpansionOccurred(editor:ICommonCodeEditor) {
@ -136,8 +130,14 @@ export class BasicEmmetEditorAction extends EmmetEditorAction {
private emmetActionName: string;
constructor(id:string, label:string, alias:string, actionName: string) {
super(id, label, alias);
constructor(id:string, label:string, alias:string, actionName: string, kbOpts?:ICommandKeybindingsOptions) {
super({
id: id,
label: label,
alias: alias,
precondition: EditorContextKeys.Writable,
kbOpts: kbOpts
});
this.emmetActionName = actionName;
}