diff --git a/src/vs/workbench/browser/parts/editor/editorActions.ts b/src/vs/workbench/browser/parts/editor/editorActions.ts index 3f03c99402aade24198bbbb715345d3c3a2858b5..11d6d32fe9c7eb011d140c0efec17fae218838f5 100644 --- a/src/vs/workbench/browser/parts/editor/editorActions.ts +++ b/src/vs/workbench/browser/parts/editor/editorActions.ts @@ -23,7 +23,9 @@ import { ICommandService } from 'vs/platform/commands/common/commands'; import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles'; import { IWindowsService } from 'vs/platform/windows/common/windows'; import { CLOSE_EDITOR_COMMAND_ID, NAVIGATE_IN_GROUP_ONE_PREFIX, NAVIGATE_ALL_EDITORS_GROUP_PREFIX, NAVIGATE_IN_GROUP_THREE_PREFIX, NAVIGATE_IN_GROUP_TWO_PREFIX } from 'vs/workbench/browser/parts/editor/editorCommands'; +import { INextEditorGroupsService, Direction as SplitDirection, INextEditorGroup, CopyKind } from 'vs/workbench/services/editor/common/nextEditorGroupsService'; +// TODo@grid this action should be removed in favour of the split vertical/horizontal actions export class SplitEditorAction extends Action { public static readonly ID = 'workbench.action.splitEditor'; @@ -107,6 +109,64 @@ export class SplitEditorAction extends Action { } } +export class BaseSplitEditorGroupAction extends Action { + + constructor( + id: string, + label: string, + clazz: string, + private direction: SplitDirection, + private nextEditorGroupsService: INextEditorGroupsService + ) { + super(id, label, clazz); + } + + public run(context?: IEditorIdentifier): TPromise { + let group: INextEditorGroup; + if (context && context.group) { + group = this.nextEditorGroupsService.getGroup(context.group.id); + } + + if (!group) { + group = this.nextEditorGroupsService.activeGroup; + } + + const copyKind = group.activeEditor instanceof EditorInput && group.activeEditor.supportsSplitEditor() ? CopyKind.EDITOR : void 0; + + this.nextEditorGroupsService.addGroup(group, this.direction, copyKind); + + return TPromise.as(true); + } +} + +export class SplitEditorGroupVerticalAction extends BaseSplitEditorGroupAction { + + public static readonly ID = 'workbench.action.splitEditorGroupVertical'; + public static readonly LABEL = nls.localize('splitEditorGroupVertical', "Split Editor Group Vertically"); + + constructor( + id: string, + label: string, + @INextEditorGroupsService nextEditorGroupsService: INextEditorGroupsService + ) { + super(id, label, 'split-editor-vertical-action', SplitDirection.DOWN, nextEditorGroupsService); + } +} + +export class SplitEditorGroupHorizontalAction extends BaseSplitEditorGroupAction { + + public static readonly ID = 'workbench.action.splitEditorGroupHorizontal'; + public static readonly LABEL = nls.localize('splitEditorGroupHorizontal', "Split Editor Group Horizontally"); + + constructor( + id: string, + label: string, + @INextEditorGroupsService nextEditorGroupsService: INextEditorGroupsService + ) { + super(id, label, 'split-editor-horizontal-action', SplitDirection.RIGHT, nextEditorGroupsService); + } +} + export class JoinTwoGroupsAction extends Action { public static readonly ID = 'workbench.action.joinTwoGroups'; diff --git a/src/vs/workbench/browser/parts/editor2/media/nextTitleControl.css b/src/vs/workbench/browser/parts/editor2/media/nextTitleControl.css index 008056e8ffa037c6cbec87f6ab268b63a87d079a..4f6c5cc51334ba668cceedfb5f7595472415e2b0 100644 --- a/src/vs/workbench/browser/parts/editor2/media/nextTitleControl.css +++ b/src/vs/workbench/browser/parts/editor2/media/nextTitleControl.css @@ -86,20 +86,20 @@ /** TODO@grid revisit the split editor action (vertical-layout/horizontal-layout does not exist anymore) */ -.monaco-workbench > .part.editor > .content .editor-group-container > .title .split-editor-right-action { - background: url('split-editor-vertical.svg') center center no-repeat; +.monaco-workbench > .part.editor > .content .editor-group-container > .title .split-editor-horizontal-action { + background: url('split-editor-horizontal.svg') center center no-repeat; } -.vs-dark .monaco-workbench > .part.editor > .content .editor-group-container > .title .split-editor-right-action, -.hc-black .monaco-workbench > .part.editor > .content .editor-group-container > .title .split-editor-right-action { - background: url('split-editor-vertical-inverse.svg') center center no-repeat; +.vs-dark .monaco-workbench > .part.editor > .content .editor-group-container > .title .split-editor-horizontal-action, +.hc-black .monaco-workbench > .part.editor > .content .editor-group-container > .title .split-editor-horizontal-action { + background: url('split-editor-horizontal-inverse.svg') center center no-repeat; } -.monaco-workbench > .part.editor > .content .editor-group-container > .title .split-editor-down-action { - background: url('split-editor-horizontal.svg') center center no-repeat; +.monaco-workbench > .part.editor > .content .editor-group-container > .title .split-editor-vertical-action { + background: url('split-editor-vertical.svg') center center no-repeat; } -.vs-dark .monaco-workbench > .part.editor > .content .editor-group-container > .title .split-editor-down-action, -.hc-black .monaco-workbench > .part.editor > .content .editor-group-container > .title .split-editor-down-action { - background: url('split-editor-horizontal-inverse.svg') center center no-repeat; +.vs-dark .monaco-workbench > .part.editor > .content .editor-group-container > .title .split-editor-vertical-action, +.hc-black .monaco-workbench > .part.editor > .content .editor-group-container > .title .split-editor-vertical-action { + background: url('split-editor-vertical-inverse.svg') center center no-repeat; } \ No newline at end of file diff --git a/src/vs/workbench/browser/parts/editor2/media/split-editor-horizontal-inverse.svg b/src/vs/workbench/browser/parts/editor2/media/split-editor-horizontal-inverse.svg index 4969d2e785116289475dfc0f2f70332f9f3c24ed..4eab75366980a9cbd5647a8856b9b2d7e7cf9490 100644 --- a/src/vs/workbench/browser/parts/editor2/media/split-editor-horizontal-inverse.svg +++ b/src/vs/workbench/browser/parts/editor2/media/split-editor-horizontal-inverse.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/vs/workbench/browser/parts/editor2/media/split-editor-horizontal.svg b/src/vs/workbench/browser/parts/editor2/media/split-editor-horizontal.svg index c307f0142b86072b801d0de11f3e9ab1660bad99..3eeaf7c53624f4f3e87f42e9aa648312362ed79e 100644 --- a/src/vs/workbench/browser/parts/editor2/media/split-editor-horizontal.svg +++ b/src/vs/workbench/browser/parts/editor2/media/split-editor-horizontal.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/vs/workbench/browser/parts/editor2/media/split-editor-vertical-inverse.svg b/src/vs/workbench/browser/parts/editor2/media/split-editor-vertical-inverse.svg index 4eab75366980a9cbd5647a8856b9b2d7e7cf9490..4969d2e785116289475dfc0f2f70332f9f3c24ed 100644 --- a/src/vs/workbench/browser/parts/editor2/media/split-editor-vertical-inverse.svg +++ b/src/vs/workbench/browser/parts/editor2/media/split-editor-vertical-inverse.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/vs/workbench/browser/parts/editor2/media/split-editor-vertical.svg b/src/vs/workbench/browser/parts/editor2/media/split-editor-vertical.svg index 3eeaf7c53624f4f3e87f42e9aa648312362ed79e..c307f0142b86072b801d0de11f3e9ab1660bad99 100644 --- a/src/vs/workbench/browser/parts/editor2/media/split-editor-vertical.svg +++ b/src/vs/workbench/browser/parts/editor2/media/split-editor-vertical.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/vs/workbench/browser/parts/editor2/nextTitleControl.ts b/src/vs/workbench/browser/parts/editor2/nextTitleControl.ts index 15be6e178716cef26091ebed4c23e109de054ba3..6461d503033d94ba5481f1e5b2e3fa02f515c05e 100644 --- a/src/vs/workbench/browser/parts/editor2/nextTitleControl.ts +++ b/src/vs/workbench/browser/parts/editor2/nextTitleControl.ts @@ -24,7 +24,7 @@ import { IQuickOpenService } from 'vs/platform/quickOpen/common/quickOpen'; import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; import { ResolvedKeybinding } from 'vs/base/common/keyCodes'; import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; -import { SplitEditorAction, CloseOneEditorAction } from 'vs/workbench/browser/parts/editor/editorActions'; +import { CloseOneEditorAction, SplitEditorGroupVerticalAction, SplitEditorGroupHorizontalAction } from 'vs/workbench/browser/parts/editor/editorActions'; import { IDisposable, dispose } from 'vs/base/common/lifecycle'; import { createActionItem, fillInActions } from 'vs/platform/actions/browser/menuItemActionItem'; import { IMenuService, MenuId, IMenu, ExecuteCommandAction } from 'vs/platform/actions/common/actions'; @@ -35,7 +35,7 @@ import { isDiffEditor, isCodeEditor } from 'vs/editor/browser/editorBrowser'; import { INotificationService } from 'vs/platform/notification/common/notification'; import { Dimension } from 'vs/base/browser/dom'; import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions'; -import { INextEditorGroupsService, Direction, INextEditorGroup } from 'vs/workbench/services/editor/common/nextEditorGroupsService'; +import { INextEditorGroupsService, INextEditorGroup } from 'vs/workbench/services/editor/common/nextEditorGroupsService'; import { IEditorInput } from 'vs/platform/editor/common/editor'; export interface IToolbarActions { @@ -60,7 +60,6 @@ export abstract class NextTitleControl extends Themable implements INextTitleAre protected stacks: IEditorStacksModel; protected closeOneEditorAction: CloseOneEditorAction; - protected splitEditorAction: SplitEditorAction; private currentPrimaryEditorActionIds: string[] = []; private currentSecondaryEditorActionIds: string[] = []; @@ -74,6 +73,9 @@ export abstract class NextTitleControl extends Themable implements INextTitleAre private resourceContext: ResourceContextKey; private disposeOnEditorActions: IDisposable[] = []; + private splitEditorGroupVerticalAction: SplitEditorGroupVerticalAction; + private splitEditorGroupHorizontalAction: SplitEditorGroupHorizontalAction; + private contextMenu: IMenu; constructor( @@ -167,7 +169,8 @@ export abstract class NextTitleControl extends Themable implements INextTitleAre protected initActions(services: IInstantiationService): void { this.closeOneEditorAction = services.createInstance(CloseOneEditorAction, CloseOneEditorAction.ID, CloseOneEditorAction.LABEL); - this.splitEditorAction = services.createInstance(SplitEditorAction, SplitEditorAction.ID, SplitEditorAction.LABEL); + this.splitEditorGroupHorizontalAction = services.createInstance(SplitEditorGroupHorizontalAction, SplitEditorGroupHorizontalAction.ID, SplitEditorGroupHorizontalAction.LABEL); + this.splitEditorGroupVerticalAction = services.createInstance(SplitEditorGroupVerticalAction, SplitEditorGroupVerticalAction.ID, SplitEditorGroupVerticalAction.LABEL); } protected createEditorActionsToolBar(container: HTMLElement): void { @@ -276,22 +279,9 @@ export abstract class NextTitleControl extends Themable implements INextTitleAre // Primary actions only for the active group if (isActive) { primaryEditorActions = prepareActions(editorActions.primary); - if (editor instanceof EditorInput && editor.supportsSplitEditor()) { - // TODO@grid temporary actions to play with - // primaryEditorActions.push(this.splitEditorAction); - - primaryEditorActions.push(new Action('split.right', 'Split Right', 'split-editor-right-action', true, () => { - this.nextEditorGroupsService.addGroup(this.nextEditorGroupsService.activeGroup, Direction.RIGHT, { copyEditor: true }); - - return TPromise.as(true); - })); - primaryEditorActions.push(new Action('split.down', 'Split Down', 'split-editor-down-action', true, () => { - this.nextEditorGroupsService.addGroup(this.nextEditorGroupsService.activeGroup, Direction.DOWN, { copyEditor: true }); - - return TPromise.as(true); - })); - } + primaryEditorActions.push(this.splitEditorGroupHorizontalAction); + primaryEditorActions.push(this.splitEditorGroupVerticalAction); } secondaryEditorActions = prepareActions(editorActions.secondary); @@ -415,7 +405,8 @@ export abstract class NextTitleControl extends Themable implements INextTitleAre // Actions [ - this.splitEditorAction, + this.splitEditorGroupHorizontalAction, + this.splitEditorGroupVerticalAction, this.closeOneEditorAction ].forEach((action) => { action.dispose();