Skip to content

Commit

Permalink
Showing 6 changed files with 101 additions and 64 deletions.
8 changes: 7 additions & 1 deletion src/vs/workbench/browser/contextkeys.ts
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ import { Event } from 'vs/base/common/event';
import { Disposable } from 'vs/base/common/lifecycle';
import { IContextKeyService, IContextKey, RawContextKey } from 'vs/platform/contextkey/common/contextkey';
import { InputFocusedContext, IsMacContext, IsLinuxContext, IsWindowsContext, IsWebContext, IsMacNativeContext, IsDevelopmentContext, IsIOSContext } from 'vs/platform/contextkey/common/contextkeys';
import { ActiveEditorContext, EditorsVisibleContext, TextCompareEditorVisibleContext, TextCompareEditorActiveContext, ActiveEditorGroupEmptyContext, MultipleEditorGroupsContext, TEXT_DIFF_EDITOR_ID, SplitEditorsVertically, InEditorZenModeContext, IsCenteredLayoutContext, ActiveEditorGroupIndexContext, ActiveEditorGroupLastContext, ActiveEditorReadonlyContext, EditorAreaVisibleContext, ActiveEditorAvailableEditorIdsContext, EditorInputCapabilities, ActiveEditorCanRevertContext, ActiveEditorGroupLockedContext, ActiveEditorCanSplitInGroupContext } from 'vs/workbench/common/editor';
import { ActiveEditorContext, EditorsVisibleContext, TextCompareEditorVisibleContext, TextCompareEditorActiveContext, ActiveEditorGroupEmptyContext, MultipleEditorGroupsContext, TEXT_DIFF_EDITOR_ID, SplitEditorsVertically, InEditorZenModeContext, IsCenteredLayoutContext, ActiveEditorGroupIndexContext, ActiveEditorGroupLastContext, ActiveEditorReadonlyContext, EditorAreaVisibleContext, ActiveEditorAvailableEditorIdsContext, EditorInputCapabilities, ActiveEditorCanRevertContext, ActiveEditorGroupLockedContext, ActiveEditorCanSplitInGroupContext, SideBySideEditorActiveContext, SIDE_BY_SIDE_EDITOR_ID } from 'vs/workbench/common/editor';
import { trackFocus, addDisposableListener, EventType, WebFileSystemAccess } from 'vs/base/browser/dom';
import { preferredSideBySideGroupDirection, GroupDirection, IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
@@ -59,8 +59,11 @@ export class WorkbenchContextKeysHandler extends Disposable {
private multipleEditorGroupsContext: IContextKey<boolean>;

private editorsVisibleContext: IContextKey<boolean>;

private textCompareEditorVisibleContext: IContextKey<boolean>;
private textCompareEditorActiveContext: IContextKey<boolean>;

private sideBySideEditorActiveContext: IContextKey<boolean>;
private splitEditorsVerticallyContext: IContextKey<boolean>;

private workbenchStateContext: IContextKey<string>;
@@ -124,6 +127,7 @@ export class WorkbenchContextKeysHandler extends Disposable {
this.editorsVisibleContext = EditorsVisibleContext.bindTo(this.contextKeyService);
this.textCompareEditorVisibleContext = TextCompareEditorVisibleContext.bindTo(this.contextKeyService);
this.textCompareEditorActiveContext = TextCompareEditorActiveContext.bindTo(this.contextKeyService);
this.sideBySideEditorActiveContext = SideBySideEditorActiveContext.bindTo(this.contextKeyService);
this.activeEditorGroupEmpty = ActiveEditorGroupEmptyContext.bindTo(this.contextKeyService);
this.activeEditorGroupIndex = ActiveEditorGroupIndexContext.bindTo(this.contextKeyService);
this.activeEditorGroupLast = ActiveEditorGroupLastContext.bindTo(this.contextKeyService);
@@ -250,6 +254,8 @@ export class WorkbenchContextKeysHandler extends Disposable {
this.textCompareEditorActiveContext.set(activeEditorPane?.getId() === TEXT_DIFF_EDITOR_ID);
this.textCompareEditorVisibleContext.set(visibleEditorPanes.some(editorPane => editorPane.getId() === TEXT_DIFF_EDITOR_ID));

this.sideBySideEditorActiveContext.set(activeEditorPane?.getId() === SIDE_BY_SIDE_EDITOR_ID);

if (visibleEditorPanes.length > 0) {
this.editorsVisibleContext.set(true);
} else {
12 changes: 6 additions & 6 deletions src/vs/workbench/browser/parts/editor/editor.contribution.ts
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ import { URI } from 'vs/base/common/uri';
import { IEditorPaneRegistry, EditorPaneDescriptor } from 'vs/workbench/browser/editor';
import {
IEditorFactoryRegistry, TextCompareEditorActiveContext, ActiveEditorPinnedContext, EditorExtensions, EditorGroupEditorsCountContext,
ActiveEditorStickyContext, ActiveEditorAvailableEditorIdsContext, MultipleEditorGroupsContext, ActiveEditorDirtyContext, ActiveEditorGroupLockedContext, ActiveEditorCanSplitInGroupContext, ActiveEditorContext
ActiveEditorStickyContext, ActiveEditorAvailableEditorIdsContext, MultipleEditorGroupsContext, ActiveEditorDirtyContext, ActiveEditorGroupLockedContext, ActiveEditorCanSplitInGroupContext, SideBySideEditorActiveContext
} from 'vs/workbench/common/editor';
import { SideBySideEditorInput, SideBySideEditorInputSerializer } from 'vs/workbench/common/editor/sideBySideEditorInput';
import { TextResourceEditor } from 'vs/workbench/browser/parts/editor/textResourceEditor';
@@ -319,7 +319,7 @@ MenuRegistry.appendMenuItem(MenuId.EditorTitleContext, { command: { id: SPLIT_ED
MenuRegistry.appendMenuItem(MenuId.EditorTitleContext, { command: { id: SPLIT_EDITOR_LEFT, title: localize('splitLeft', "Split Left") }, group: '5_split', order: 30 });
MenuRegistry.appendMenuItem(MenuId.EditorTitleContext, { command: { id: SPLIT_EDITOR_RIGHT, title: localize('splitRight', "Split Right") }, group: '5_split', order: 40 });
MenuRegistry.appendMenuItem(MenuId.EditorTitleContext, { command: { id: SPLIT_EDITOR_IN_GROUP, title: localize('splitInGroup', "Split in Group") }, group: '6_split_in_group', order: 10, when: ActiveEditorCanSplitInGroupContext });
MenuRegistry.appendMenuItem(MenuId.EditorTitleContext, { command: { id: JOIN_EDITOR_IN_GROUP, title: localize('joinInGroup', "Join in Group") }, group: '6_split_in_group', order: 10, when: ActiveEditorContext.isEqualTo(SideBySideEditor.ID) });
MenuRegistry.appendMenuItem(MenuId.EditorTitleContext, { command: { id: JOIN_EDITOR_IN_GROUP, title: localize('joinInGroup', "Join in Group") }, group: '6_split_in_group', order: 10, when: SideBySideEditorActiveContext });

// Editor Title Menu
MenuRegistry.appendMenuItem(MenuId.EditorTitle, { command: { id: TOGGLE_DIFF_SIDE_BY_SIDE, title: localize('inlineView', "Inline View"), toggled: ContextKeyExpr.equals('config.diffEditor.renderSideBySide', false) }, group: '1_diff', order: 10, when: ContextKeyExpr.has('isInDiffEditor') });
@@ -396,7 +396,7 @@ appendEditorToolItem(
title: localize('toggleSplitEditorInGroupLayout', "Toggle Layout"),
icon: Codicon.editorLayout
},
ActiveEditorContext.isEqualTo(SideBySideEditor.ID),
SideBySideEditorActiveContext,
SPLIT_ORDER - 1, // left to split actions
);

@@ -616,7 +616,7 @@ MenuRegistry.appendMenuItem(MenuId.MenubarLayoutMenu, {
id: JOIN_EDITOR_IN_GROUP,
title: localize({ key: 'miJoinEditorInGroup', comment: ['&& denotes a mnemonic'] }, "Join in &&Group")
},
when: ActiveEditorContext.isEqualTo(SideBySideEditor.ID),
when: SideBySideEditorActiveContext,
order: 1
});

@@ -733,7 +733,7 @@ MenuRegistry.appendMenuItem(MenuId.MenubarSwitchEditorMenu, {
id: FOCUS_FIRST_SIDE_EDITOR,
title: localize({ key: 'miFirstSideEditor', comment: ['&& denotes a mnemonic'] }, "&&First Side in Editor")
},
when: ContextKeyExpr.or(ActiveEditorContext.isEqualTo(SideBySideEditor.ID), ActiveEditorContext.isEqualTo(TextDiffEditor.ID)),
when: ContextKeyExpr.or(SideBySideEditorActiveContext, TextCompareEditorActiveContext),
order: 1
});

@@ -743,7 +743,7 @@ MenuRegistry.appendMenuItem(MenuId.MenubarSwitchEditorMenu, {
id: FOCUS_SECOND_SIDE_EDITOR,
title: localize({ key: 'miSecondSideEditor', comment: ['&& denotes a mnemonic'] }, "&&Second Side in Editor")
},
when: ContextKeyExpr.or(ActiveEditorContext.isEqualTo(SideBySideEditor.ID), ActiveEditorContext.isEqualTo(TextDiffEditor.ID)),
when: ContextKeyExpr.or(SideBySideEditorActiveContext, TextCompareEditorActiveContext),
order: 2
});

117 changes: 63 additions & 54 deletions src/vs/workbench/browser/parts/editor/editorCommands.ts
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ import { localize } from 'vs/nls';
import { isObject, isString, isUndefined, isNumber, withNullAsUndefined } from 'vs/base/common/types';
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { KeybindingsRegistry, KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
import { TextCompareEditorVisibleContext, IEditorIdentifier, IEditorCommandsContext, ActiveEditorGroupEmptyContext, MultipleEditorGroupsContext, CloseDirection, IEditorInput, IVisibleEditorPane, ActiveEditorStickyContext, EditorsOrder, EditorInputCapabilities, isEditorIdentifier, ActiveEditorGroupLockedContext, ActiveEditorContext, ActiveEditorCanSplitInGroupContext, GroupIdentifier } from 'vs/workbench/common/editor';
import { TextCompareEditorVisibleContext, IEditorIdentifier, IEditorCommandsContext, ActiveEditorGroupEmptyContext, MultipleEditorGroupsContext, CloseDirection, IEditorInput, IVisibleEditorPane, ActiveEditorStickyContext, EditorsOrder, EditorInputCapabilities, isEditorIdentifier, ActiveEditorGroupLockedContext, ActiveEditorCanSplitInGroupContext, GroupIdentifier, TextCompareEditorActiveContext, SideBySideEditorActiveContext } from 'vs/workbench/common/editor';
import { EditorGroupColumn, columnToEditorGroup } from 'vs/workbench/services/editor/common/editorGroupColumn';
import { ACTIVE_GROUP_TYPE, IEditorService, SIDE_GROUP, SIDE_GROUP_TYPE } from 'vs/workbench/services/editor/common/editorService';
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
@@ -29,7 +29,6 @@ import { IOpenerService } from 'vs/platform/opener/common/opener';
import { EditorResolution, IEditorOptions, ITextEditorOptions } from 'vs/platform/editor/common/editor';
import { Schemas } from 'vs/base/common/network';
import { SideBySideEditorInput } from 'vs/workbench/common/editor/sideBySideEditorInput';
import { EditorInput } from 'vs/workbench/common/editor/editorInput';
import { SideBySideEditor } from 'vs/workbench/browser/parts/editor/sideBySideEditor';

export const CLOSE_SAVED_EDITORS_COMMAND_ID = 'workbench.action.closeUnmodifiedEditors';
@@ -420,7 +419,7 @@ function registerDiffEditorCommands(): void {
},
category: localize('compare', "Compare")
},
when: ContextKeyExpr.has('textCompareEditorActive')
when: TextCompareEditorActiveContext
});

KeybindingsRegistry.registerCommandAndKeybindingRule({
@@ -948,11 +947,26 @@ function registerFocusEditorGroupWihoutWrapCommands(): void {

function registerSplitEditorInGroupCommands(): void {

async function splitEditorInGroup(accessor: ServicesAccessor, resourceOrContext?: URI | IEditorCommandsContext, context?: IEditorCommandsContext): Promise<void> {
const editorGroupService = accessor.get(IEditorGroupsService);

const { group, editor } = resolveCommandsContext(editorGroupService, getCommandsContext(resourceOrContext, context));
if (!editor) {
return;
}

await group.replaceEditors([{
editor,
replacement: new SideBySideEditorInput(undefined, undefined, editor, editor),
forceReplaceDirty: true
}]);
}

registerAction2(class extends Action2 {
constructor() {
super({
id: SPLIT_EDITOR_IN_GROUP,
title: localize('splitEditorInGroup', "Split Active Editor in Group"),
title: localize('splitEditorInGroup', "Split Editor in Group"),
category: CATEGORIES.View,
precondition: ActiveEditorCanSplitInGroupContext,
f1: true,
@@ -963,80 +977,75 @@ function registerSplitEditorInGroupCommands(): void {
}
});
}
async run(accessor: ServicesAccessor): Promise<void> {
const editorService = accessor.get(IEditorService);
run(accessor: ServicesAccessor, resourceOrContext?: URI | IEditorCommandsContext, context?: IEditorCommandsContext): Promise<void> {
return splitEditorInGroup(accessor, resourceOrContext, context);
}
});

const activeEditorPane = editorService.activeEditorPane;
if (!(activeEditorPane?.input instanceof EditorInput)) {
return;
}
async function joinEditorInGroup(accessor: ServicesAccessor, resourceOrContext?: URI | IEditorCommandsContext, context?: IEditorCommandsContext): Promise<void> {
const editorGroupService = accessor.get(IEditorGroupsService);

await activeEditorPane.group.replaceEditors([{
editor: activeEditorPane.input,
replacement: new SideBySideEditorInput(undefined, undefined, activeEditorPane.input, activeEditorPane.input),
forceReplaceDirty: true
}]);
const { group, editor } = resolveCommandsContext(editorGroupService, getCommandsContext(resourceOrContext, context));
if (!(editor instanceof SideBySideEditorInput)) {
return;
}
});

let options: IEditorOptions | undefined = undefined;
const activeEditorPane = group.activeEditorPane;
if (activeEditorPane instanceof SideBySideEditor && group.activeEditor === editor) {
for (const pane of [activeEditorPane.getPrimaryEditorPane(), activeEditorPane.getSecondaryEditorPane()]) {
if (pane?.hasFocus()) {
options = { viewState: pane.getViewState() };
break;
}
}
}

await group.replaceEditors([{
editor,
replacement: editor.primary,
options
}]);
}

registerAction2(class extends Action2 {
constructor() {
super({
id: JOIN_EDITOR_IN_GROUP,
title: localize('joinEditorInGroup', "Join Active Editor in Group"),
title: localize('joinEditorInGroup', "Join Editor in Group"),
category: CATEGORIES.View,
precondition: ActiveEditorContext.isEqualTo(SideBySideEditor.ID),
precondition: SideBySideEditorActiveContext,
f1: true,
keybinding: {
weight: KeybindingWeight.WorkbenchContrib,
when: ActiveEditorContext.isEqualTo(SideBySideEditor.ID),
when: SideBySideEditorActiveContext,
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.US_BACKSLASH)
}
});
}
async run(accessor: ServicesAccessor): Promise<void> {
const editorService = accessor.get(IEditorService);

const activeEditorPane = editorService.activeEditorPane;
if (!(activeEditorPane instanceof SideBySideEditor) || !(activeEditorPane.input instanceof SideBySideEditorInput)) {
return;
}

let options: IEditorOptions | undefined = undefined;
for (const pane of [activeEditorPane.getPrimaryEditorPane(), activeEditorPane.getSecondaryEditorPane()]) {
if (pane?.hasFocus()) {
options = { viewState: pane.getViewState() };
break;
}
}

await activeEditorPane.group.replaceEditors([{
editor: activeEditorPane.input,
replacement: activeEditorPane.input.primary,
options
}]);
run(accessor: ServicesAccessor, resourceOrContext?: URI | IEditorCommandsContext, context?: IEditorCommandsContext): Promise<void> {
return joinEditorInGroup(accessor, resourceOrContext, context);
}
});

registerAction2(class extends Action2 {
constructor() {
super({
id: TOGGLE_SPLIT_EDITOR_IN_GROUP,
title: localize('toggleJoinEditorInGroup', "Toggle Split Active Editor in Group"),
title: localize('toggleJoinEditorInGroup', "Toggle Split Editor in Group"),
category: CATEGORIES.View,
precondition: ContextKeyExpr.or(ActiveEditorCanSplitInGroupContext, ActiveEditorContext.isEqualTo(SideBySideEditor.ID)),
precondition: ContextKeyExpr.or(ActiveEditorCanSplitInGroupContext, SideBySideEditorActiveContext),
f1: true
});
}
async run(accessor: ServicesAccessor): Promise<void> {
const editorService = accessor.get(IEditorService);
const commandService = accessor.get(ICommandService);
async run(accessor: ServicesAccessor, resourceOrContext?: URI | IEditorCommandsContext, context?: IEditorCommandsContext): Promise<void> {
const editorGroupService = accessor.get(IEditorGroupsService);

const activeEditorPane = editorService.activeEditorPane;
if (activeEditorPane?.input instanceof SideBySideEditorInput) {
await commandService.executeCommand(JOIN_EDITOR_IN_GROUP);
} else if (activeEditorPane?.input) {
await commandService.executeCommand(SPLIT_EDITOR_IN_GROUP);
const { editor } = resolveCommandsContext(editorGroupService, getCommandsContext(resourceOrContext, context));
if (editor instanceof SideBySideEditorInput) {
await joinEditorInGroup(accessor, resourceOrContext, context);
} else if (editor) {
await splitEditorInGroup(accessor, resourceOrContext, context);
}
}
});
@@ -1047,7 +1056,7 @@ function registerSplitEditorInGroupCommands(): void {
id: TOGGLE_SPLIT_EDITOR_IN_GROUP_LAYOUT,
title: localize('toggleSplitEditorInGroupLayout', "Toggle Split Editor in Group Layout"),
category: CATEGORIES.View,
precondition: ActiveEditorContext.isEqualTo(SideBySideEditor.ID),
precondition: SideBySideEditorActiveContext,
f1: true
});
}
@@ -1075,7 +1084,7 @@ function registerFocusSideEditorsCommands(): void {
id: FOCUS_FIRST_SIDE_EDITOR,
title: localize('focusLeftSideEditor', "Focus First Side in Active Editor"),
category: CATEGORIES.View,
precondition: ContextKeyExpr.or(ActiveEditorContext.isEqualTo(SideBySideEditor.ID), ActiveEditorContext.isEqualTo(TextDiffEditor.ID)),
precondition: ContextKeyExpr.or(SideBySideEditorActiveContext, TextCompareEditorActiveContext),
f1: true
});
}
@@ -1098,7 +1107,7 @@ function registerFocusSideEditorsCommands(): void {
id: FOCUS_SECOND_SIDE_EDITOR,
title: localize('focusRightSideEditor', "Focus Second Side in Active Editor"),
category: CATEGORIES.View,
precondition: ContextKeyExpr.or(ActiveEditorContext.isEqualTo(SideBySideEditor.ID), ActiveEditorContext.isEqualTo(TextDiffEditor.ID)),
precondition: ContextKeyExpr.or(SideBySideEditorActiveContext, TextCompareEditorActiveContext),
f1: true
});
}
@@ -1121,7 +1130,7 @@ function registerFocusSideEditorsCommands(): void {
id: FOCUS_OTHER_SIDE_EDITOR,
title: localize('focusOtherSideEditor', "Focus Other Side in Active Editor"),
category: CATEGORIES.View,
precondition: ContextKeyExpr.or(ActiveEditorContext.isEqualTo(SideBySideEditor.ID), ActiveEditorContext.isEqualTo(TextDiffEditor.ID)),
precondition: ContextKeyExpr.or(SideBySideEditorActiveContext, TextCompareEditorActiveContext),
f1: true
});
}
4 changes: 2 additions & 2 deletions src/vs/workbench/browser/parts/editor/sideBySideEditor.ts
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ import 'vs/css!./media/sidebysideeditor';
import { localize } from 'vs/nls';
import { Dimension, $, clearNode } from 'vs/base/browser/dom';
import { Registry } from 'vs/platform/registry/common/platform';
import { IEditorControl, IEditorPane, IEditorOpenContext, EditorExtensions } from 'vs/workbench/common/editor';
import { IEditorControl, IEditorPane, IEditorOpenContext, EditorExtensions, SIDE_BY_SIDE_EDITOR_ID } from 'vs/workbench/common/editor';
import { SideBySideEditorInput } from 'vs/workbench/common/editor/sideBySideEditorInput';
import { EditorInput } from 'vs/workbench/common/editor/editorInput';
import { EditorPane } from 'vs/workbench/browser/parts/editor/editorPane';
@@ -34,7 +34,7 @@ enum Side {

export class SideBySideEditor extends EditorPane {

static readonly ID: string = 'workbench.editor.sidebysideEditor';
static readonly ID: string = SIDE_BY_SIDE_EDITOR_ID;

static SIDE_BY_SIDE_LAYOUT_SETTING = 'workbench.editor.splitInGroupLayout';

18 changes: 17 additions & 1 deletion src/vs/workbench/browser/parts/editor/titleControl.ts
Original file line number Diff line number Diff line change
@@ -30,13 +30,14 @@ import { EditorPane } from 'vs/workbench/browser/parts/editor/editorPane';
import { BreadcrumbsConfig } from 'vs/workbench/browser/parts/editor/breadcrumbs';
import { BreadcrumbsControl, IBreadcrumbsControlOptions } from 'vs/workbench/browser/parts/editor/breadcrumbsControl';
import { IEditorGroupsAccessor, IEditorGroupTitleHeight, IEditorGroupView } from 'vs/workbench/browser/parts/editor/editor';
import { IEditorCommandsContext, IEditorInput, EditorResourceAccessor, IEditorPartOptions, SideBySideEditor, ActiveEditorPinnedContext, ActiveEditorStickyContext, EditorsOrder, ActiveEditorGroupLockedContext } from 'vs/workbench/common/editor';
import { IEditorCommandsContext, IEditorInput, EditorResourceAccessor, IEditorPartOptions, SideBySideEditor, ActiveEditorPinnedContext, ActiveEditorStickyContext, EditorsOrder, ActiveEditorGroupLockedContext, ActiveEditorCanSplitInGroupContext, EditorInputCapabilities, SideBySideEditorActiveContext } from 'vs/workbench/common/editor';
import { ResourceContextKey } from 'vs/workbench/common/resources';
import { AnchorAlignment } from 'vs/base/browser/ui/contextview/contextview';
import { IFileService } from 'vs/platform/files/common/files';
import { withNullAsUndefined, withUndefinedAsNull, assertIsDefined } from 'vs/base/common/types';
import { isFirefox } from 'vs/base/browser/browser';
import { isPromiseCanceledError } from 'vs/base/common/errors';
import { SideBySideEditorInput } from 'vs/workbench/common/editor/sideBySideEditorInput';

export interface IToolbarActions {
primary: IAction[];
@@ -84,6 +85,9 @@ export abstract class TitleControl extends Themable {
private editorPinnedContext: IContextKey<boolean>;
private editorStickyContext: IContextKey<boolean>;

private editorCanSplitInGroupContext: IContextKey<boolean>;
private sideBySideEditorContext: IContextKey<boolean>;

private groupLockedContext: IContextKey<boolean>;

private readonly editorToolBarMenuDisposables = this._register(new DisposableStore());
@@ -114,6 +118,9 @@ export abstract class TitleControl extends Themable {
this.editorPinnedContext = ActiveEditorPinnedContext.bindTo(contextKeyService);
this.editorStickyContext = ActiveEditorStickyContext.bindTo(contextKeyService);

this.editorCanSplitInGroupContext = ActiveEditorCanSplitInGroupContext.bindTo(contextKeyService);
this.sideBySideEditorContext = SideBySideEditorActiveContext.bindTo(contextKeyService);

this.groupLockedContext = ActiveEditorGroupLockedContext.bindTo(contextKeyService);

this.contextMenu = this._register(this.menuService.createMenu(MenuId.EditorTitleContext, this.contextKeyService));
@@ -221,6 +228,9 @@ export abstract class TitleControl extends Themable {
this.editorPinnedContext.set(this.group.activeEditor ? this.group.isPinned(this.group.activeEditor) : false);
this.editorStickyContext.set(this.group.activeEditor ? this.group.isSticky(this.group.activeEditor) : false);

this.editorCanSplitInGroupContext.set(this.group.activeEditor ? this.group.activeEditor.hasCapability(EditorInputCapabilities.CanSplitInGroup) : false);
this.sideBySideEditorContext.set(this.group.activeEditor?.typeId === SideBySideEditorInput.ID);

this.groupLockedContext.set(this.group.isLocked);
});

@@ -323,6 +333,10 @@ export abstract class TitleControl extends Themable {
this.editorStickyContext.set(this.group.isSticky(editor));
const currentGroupLockedContext = !!this.groupLockedContext.get();
this.groupLockedContext.set(this.group.isLocked);
const currentEditorCanSplitContext = !!this.editorCanSplitInGroupContext.get();
this.editorCanSplitInGroupContext.set(editor.hasCapability(EditorInputCapabilities.CanSplitInGroup));
const currentSideBySideEditorContext = !!this.sideBySideEditorContext.get();
this.sideBySideEditorContext.set(editor.typeId === SideBySideEditorInput.ID);

// Find target anchor
let anchor: HTMLElement | { x: number, y: number } = node;
@@ -348,6 +362,8 @@ export abstract class TitleControl extends Themable {
this.editorPinnedContext.set(currentPinnedContext);
this.editorStickyContext.set(currentStickyContext);
this.groupLockedContext.set(currentGroupLockedContext);
this.editorCanSplitInGroupContext.set(currentEditorCanSplitContext);
this.sideBySideEditorContext.set(currentSideBySideEditorContext);

// restore focus to active group
this.accessor.activeGroup.focus();
6 changes: 6 additions & 0 deletions src/vs/workbench/common/editor.ts
Original file line number Diff line number Diff line change
@@ -49,6 +49,7 @@ export const ActiveEditorContext = new RawContextKey<string | null>('activeEdito
export const ActiveEditorAvailableEditorIdsContext = new RawContextKey<string>('activeEditorAvailableEditorIds', '', localize('activeEditorAvailableEditorIds', "The available editor identifiers that are usable for the active editor"));
export const TextCompareEditorVisibleContext = new RawContextKey<boolean>('textCompareEditorVisible', false, localize('textCompareEditorVisible', "Whether a text compare editor is visible"));
export const TextCompareEditorActiveContext = new RawContextKey<boolean>('textCompareEditorActive', false, localize('textCompareEditorActive', "Whether a text compare editor is active"));
export const SideBySideEditorActiveContext = new RawContextKey<boolean>('sideBySideEditorActive', false, localize('sideBySideEditorActive', "Whether a side by side editor is active"));

// Editor Group Context Keys
export const EditorGroupEditorsCountContext = new RawContextKey<number>('groupEditorsCount', 0, localize('groupEditorsCount', "The number of opened editor groups"));
@@ -66,6 +67,11 @@ export const IsCenteredLayoutContext = new RawContextKey<boolean>('isCenteredLay
export const SplitEditorsVertically = new RawContextKey<boolean>('splitEditorsVertically', false, localize('splitEditorsVertically', "Whether editors split vertically"));
export const EditorAreaVisibleContext = new RawContextKey<boolean>('editorAreaVisible', true, localize('editorAreaVisible', "Whether the editor area is visible"));

/**
* Side by side editor id.
*/
export const SIDE_BY_SIDE_EDITOR_ID = 'workbench.editor.sidebysideEditor';

/**
* Text diff editor id.
*/

0 comments on commit 0df5af8

Please sign in to comment.