Skip to content

Commit 3a4edc8

Browse files
author
Benjamin Pasero
committed
Add toggle.diff.editorMode to the command palette (fixes microsoft#54974)
1 parent 0615dbe commit 3a4edc8

3 files changed

Lines changed: 14 additions & 1 deletion

File tree

src/vs/workbench/browser/parts/editor/editorCommands.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { IEditorGroupsService, IEditorGroup, GroupDirection, GroupLocation, Grou
2323
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
2424
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
2525
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
26+
import { MenuRegistry, MenuId } from 'vs/platform/actions/common/actions';
2627

2728
export const CLOSE_SAVED_EDITORS_COMMAND_ID = 'workbench.action.closeUnmodifiedEditors';
2829
export const CLOSE_EDITORS_IN_GROUP_COMMAND_ID = 'workbench.action.closeEditorsInGroup';
@@ -263,6 +264,14 @@ function registerDiffEditorCommands(): void {
263264
}
264265
}
265266
});
267+
268+
MenuRegistry.appendMenuItem(MenuId.CommandPalette, {
269+
command: {
270+
id: TOGGLE_DIFF_INLINE_MODE,
271+
title: nls.localize('toggleInlineView', "Compare: Toggle Inline View")
272+
},
273+
when: ContextKeyExpr.has('textCompareEditorActive')
274+
});
266275
}
267276

268277
function registerOpenEditorAtIndexCommands(): void {

src/vs/workbench/common/editor.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export const EditorsVisibleContext = new RawContextKey<boolean>('editorIsOpen',
2525
export const EditorGroupActiveEditorDirtyContext = new RawContextKey<boolean>('groupActiveEditorDirty', false);
2626
export const NoEditorsVisibleContext: ContextKeyExpr = EditorsVisibleContext.toNegated();
2727
export const TextCompareEditorVisibleContext = new RawContextKey<boolean>('textCompareEditorVisible', false);
28+
export const TextCompareEditorActiveContext = new RawContextKey<boolean>('textCompareEditorActive', false);
2829
export const ActiveEditorGroupEmptyContext = new RawContextKey<boolean>('activeEditorGroupEmpty', false);
2930
export const MultipleEditorGroupsContext = new RawContextKey<boolean>('multipleEditorGroups', false);
3031
export const SingleEditorGroupsContext = MultipleEditorGroupsContext.toNegated();

src/vs/workbench/electron-browser/workbench.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { Registry } from 'vs/platform/registry/common/platform';
2323
import { isWindows, isLinux, isMacintosh } from 'vs/base/common/platform';
2424
import { IResourceInput } from 'vs/platform/editor/common/editor';
2525
import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions';
26-
import { IEditorInputFactoryRegistry, Extensions as EditorExtensions, TextCompareEditorVisibleContext, TEXT_DIFF_EDITOR_ID, EditorsVisibleContext, InEditorZenModeContext, ActiveEditorGroupEmptyContext, MultipleEditorGroupsContext, IUntitledResourceInput, IResourceDiffInput, SplitEditorsVertically } from 'vs/workbench/common/editor';
26+
import { IEditorInputFactoryRegistry, Extensions as EditorExtensions, TextCompareEditorVisibleContext, TEXT_DIFF_EDITOR_ID, EditorsVisibleContext, InEditorZenModeContext, ActiveEditorGroupEmptyContext, MultipleEditorGroupsContext, IUntitledResourceInput, IResourceDiffInput, SplitEditorsVertically, TextCompareEditorActiveContext } from 'vs/workbench/common/editor';
2727
import { HistoryService } from 'vs/workbench/services/history/electron-browser/history';
2828
import { ActivitybarPart } from 'vs/workbench/browser/parts/activitybar/activitybarPart';
2929
import { SidebarPart } from 'vs/workbench/browser/parts/sidebar/sidebarPart';
@@ -606,12 +606,15 @@ export class Workbench extends Disposable implements IPartService {
606606

607607
const editorsVisibleContext = EditorsVisibleContext.bindTo(this.contextKeyService);
608608
const textCompareEditorVisible = TextCompareEditorVisibleContext.bindTo(this.contextKeyService);
609+
const textCompareEditorActive = TextCompareEditorActiveContext.bindTo(this.contextKeyService);
609610
const activeEditorGroupEmpty = ActiveEditorGroupEmptyContext.bindTo(this.contextKeyService);
610611
const multipleEditorGroups = MultipleEditorGroupsContext.bindTo(this.contextKeyService);
611612

612613
const updateEditorContextKeys = () => {
614+
const activeControl = this.editorService.activeControl;
613615
const visibleEditors = this.editorService.visibleControls;
614616

617+
textCompareEditorActive.set(activeControl && activeControl.getId() === TEXT_DIFF_EDITOR_ID);
615618
textCompareEditorVisible.set(visibleEditors.some(control => control.getId() === TEXT_DIFF_EDITOR_ID));
616619

617620
if (visibleEditors.length > 0) {

0 commit comments

Comments
 (0)