From e1a7a724ef7fdc9541d13201ab54ea55ddb76450 Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Mon, 8 Aug 2016 18:26:01 +0200 Subject: [PATCH] expose commands to move an editor in a group left and right (for #10291) --- .../parts/editor/editor.contribution.ts | 6 +- .../browser/parts/editor/editorActions.ts | 56 ++++++++++++++++++- src/vs/workbench/common/editor.ts | 2 +- 3 files changed, 60 insertions(+), 4 deletions(-) diff --git a/src/vs/workbench/browser/parts/editor/editor.contribution.ts b/src/vs/workbench/browser/parts/editor/editor.contribution.ts index 046c9f7107a..f4285ab6930 100644 --- a/src/vs/workbench/browser/parts/editor/editor.contribution.ts +++ b/src/vs/workbench/browser/parts/editor/editor.contribution.ts @@ -32,8 +32,8 @@ import {KeyMod, KeyCode} from 'vs/base/common/keyCodes'; import {CloseEditorsInGroupAction, CloseEditorsInOtherGroupsAction, CloseAllEditorsAction, MoveGroupLeftAction, MoveGroupRightAction, SplitEditorAction, KeepEditorAction, CloseOtherEditorsInGroupAction, OpenToSideAction, NavigateBetweenGroupsAction, FocusFirstGroupAction, FocusSecondGroupAction, FocusThirdGroupAction, EvenGroupWidthsAction, MaximizeGroupAction, MinimizeOtherGroupsAction, FocusPreviousGroup, FocusNextGroup, ShowEditorsInLeftGroupAction, toEditorQuickOpenEntry, CloseLeftEditorsInGroupAction, CloseRightEditorsInGroupAction, OpenNextEditor, OpenPreviousEditor, NavigateBackwardsAction, NavigateForwardAction, ReopenClosedEditorAction, OpenPreviousRecentlyUsedEditorInGroupAction, NAVIGATE_IN_LEFT_GROUP_PREFIX, - GlobalQuickOpenAction, OpenPreviousEditorFromHistoryAction, QuickOpenNavigateNextAction, QuickOpenNavigatePreviousAction, ShowAllEditorsAction, NAVIGATE_ALL_EDITORS_GROUP_PREFIX, ClearEditorHistoryAction, ShowEditorsInCenterGroupAction, - NAVIGATE_IN_CENTER_GROUP_PREFIX, ShowEditorsInRightGroupAction, NAVIGATE_IN_RIGHT_GROUP_PREFIX, RemoveFromEditorHistoryAction, FocusLastEditorInStackAction, OpenNextRecentlyUsedEditorInGroupAction, MoveEditorToLeftGroupAction, MoveEditorToRightGroupAction + GlobalQuickOpenAction, OpenPreviousEditorFromHistoryAction, QuickOpenNavigateNextAction, QuickOpenNavigatePreviousAction, ShowAllEditorsAction, NAVIGATE_ALL_EDITORS_GROUP_PREFIX, ClearEditorHistoryAction, ShowEditorsInCenterGroupAction, MoveEditorRightInGroupAction, + NAVIGATE_IN_CENTER_GROUP_PREFIX, ShowEditorsInRightGroupAction, NAVIGATE_IN_RIGHT_GROUP_PREFIX, RemoveFromEditorHistoryAction, FocusLastEditorInStackAction, OpenNextRecentlyUsedEditorInGroupAction, MoveEditorToLeftGroupAction, MoveEditorToRightGroupAction, MoveEditorLeftInGroupAction } from 'vs/workbench/browser/parts/editor/editorActions'; import * as editorCommands from 'vs/workbench/browser/parts/editor/editorCommands'; @@ -258,6 +258,8 @@ registry.registerWorkbenchAction(new SyncActionDescriptor(FocusLastEditorInStack registry.registerWorkbenchAction(new SyncActionDescriptor(EvenGroupWidthsAction, EvenGroupWidthsAction.ID, EvenGroupWidthsAction.LABEL), 'View: Even Editor Group Widths', category); registry.registerWorkbenchAction(new SyncActionDescriptor(MaximizeGroupAction, MaximizeGroupAction.ID, MaximizeGroupAction.LABEL), 'View: Maximize Editor Group and Hide Sidebar', category); registry.registerWorkbenchAction(new SyncActionDescriptor(MinimizeOtherGroupsAction, MinimizeOtherGroupsAction.ID, MinimizeOtherGroupsAction.LABEL), 'View: Minimize Other Editor Groups', category); +registry.registerWorkbenchAction(new SyncActionDescriptor(MoveEditorLeftInGroupAction, MoveEditorLeftInGroupAction.ID, MoveEditorLeftInGroupAction.LABEL), 'View: Move Editor Left', category); +registry.registerWorkbenchAction(new SyncActionDescriptor(MoveEditorRightInGroupAction, MoveEditorRightInGroupAction.ID, MoveEditorRightInGroupAction.LABEL), 'View: Move Editor Right', category); registry.registerWorkbenchAction(new SyncActionDescriptor(MoveGroupLeftAction, MoveGroupLeftAction.ID, MoveGroupLeftAction.LABEL, { primary: KeyMod.chord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyCode.LeftArrow) }), 'View: Move Editor Group Left', category); registry.registerWorkbenchAction(new SyncActionDescriptor(MoveGroupRightAction, MoveGroupRightAction.ID, MoveGroupRightAction.LABEL, { primary: KeyMod.chord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyCode.RightArrow) }), 'View: Move Editor Group Right', category); registry.registerWorkbenchAction(new SyncActionDescriptor(MoveEditorToLeftGroupAction, MoveEditorToLeftGroupAction.ID, MoveEditorToLeftGroupAction.LABEL, { primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.LeftArrow, mac: { primary: KeyMod.CtrlCmd | KeyMod.WinCtrl | KeyCode.LeftArrow } }), 'View: Move Editor into Group to the Left', category); diff --git a/src/vs/workbench/browser/parts/editor/editorActions.ts b/src/vs/workbench/browser/parts/editor/editorActions.ts index 5555d09e7e6..a65103cbd49 100644 --- a/src/vs/workbench/browser/parts/editor/editorActions.ts +++ b/src/vs/workbench/browser/parts/editor/editorActions.ts @@ -7,7 +7,7 @@ import {TPromise} from 'vs/base/common/winjs.base'; import nls = require('vs/nls'); import {Action} from 'vs/base/common/actions'; -import {EditorInput, getUntitledOrFileResource, TextEditorOptions, EditorOptions, IEditorIdentifier, IEditorContext} from 'vs/workbench/common/editor'; +import {EditorInput, getUntitledOrFileResource, TextEditorOptions, EditorOptions, IEditorIdentifier, IEditorContext, ActiveEditorMoveArguments, ActiveEditorMovePositioning, ActiveEditorMovePositioningBy, EditorCommands} from 'vs/workbench/common/editor'; import {QuickOpenEntryGroup} from 'vs/base/parts/quickopen/browser/quickOpenModel'; import {EditorQuickOpenEntry, EditorQuickOpenEntryGroup, IEditorQuickOpenEntry, QuickOpenAction} from 'vs/workbench/browser/quickopen'; import {IWorkbenchEditorService} from 'vs/workbench/services/editor/common/editorService'; @@ -19,6 +19,8 @@ import {IHistoryService} from 'vs/workbench/services/history/common/history'; import {IKeybindingService} from 'vs/platform/keybinding/common/keybinding'; import {IEditorGroupService, GroupArrangement} from 'vs/workbench/services/group/common/groupService'; import {BaseTextEditor} from 'vs/workbench/browser/parts/editor/textEditor'; +import {ICommandService} from 'vs/platform/commands/common/commands'; +import {IConfigurationService} from 'vs/platform/configuration/common/configuration'; export class SplitEditorAction extends Action { @@ -1275,6 +1277,58 @@ export class FocusLastEditorInStackAction extends Action { } } +export class MoveEditorLeftInGroupAction extends Action { + + public static ID = 'workbench.action.moveEditorLeftInGroup'; + public static LABEL = nls.localize('moveEditorLeft', "Move Editor Left"); + + constructor( + id: string, + label: string, + @IConfigurationService private configurationService: IConfigurationService, + @ICommandService private commandService: ICommandService + ) { + super(id, label); + } + + public run(): TPromise { + const args: ActiveEditorMoveArguments = { + to: ActiveEditorMovePositioning.LEFT, + by: ActiveEditorMovePositioningBy.TAB, + value: 1 + }; + this.commandService.executeCommand(EditorCommands.MoveActiveEditor, args); + + return TPromise.as(true); + } +} + +export class MoveEditorRightInGroupAction extends Action { + + public static ID = 'workbench.action.moveEditorRightInGroup'; + public static LABEL = nls.localize('moveEditorRight', "Move Editor Right"); + + constructor( + id: string, + label: string, + @IConfigurationService private configurationService: IConfigurationService, + @ICommandService private commandService: ICommandService + ) { + super(id, label); + } + + public run(): TPromise { + const args: ActiveEditorMoveArguments = { + to: ActiveEditorMovePositioning.RIGHT, + by: ActiveEditorMovePositioningBy.TAB, + value: 1 + }; + this.commandService.executeCommand(EditorCommands.MoveActiveEditor, args); + + return TPromise.as(true); + } +} + export class MoveEditorToLeftGroupAction extends Action { public static ID = 'workbench.action.moveEditorToLeftGroup'; diff --git a/src/vs/workbench/common/editor.ts b/src/vs/workbench/common/editor.ts index c8b557d1b41..e64a3288bc8 100644 --- a/src/vs/workbench/common/editor.ts +++ b/src/vs/workbench/common/editor.ts @@ -843,5 +843,5 @@ export interface ActiveEditorMoveArguments { } export var EditorCommands = { - MoveActiveEditor: 'moveActiveEditor' + MoveActiveEditor: 'moveActiveEditor' }; \ No newline at end of file