Change:
This looks and reads a bit weird to me: <img width="262" alt="image" src="https://user-"This does not really do anything when I am in Column Layout which I think is even the default.
Can context menu entries be hidden when a context key condition fails?
I think or the clause of the command, I always forget: knows for sure
precondition just disables that entry, it doesn't hide it
try with:
It is the clause that defines if an item appears in the menu
In addition to hiding this when it doesn't apply: can we find a better solution for when it applies. Can we have for column mode Show Base for mixed mode (radio-logic for these two) Show Base At Top Show Base In Middle
Fixed <img width="167" alt="image" src="https://user-"
I still find this weird: <img width="198" alt="image" src="https://user-"Throwing in some ideas: Column Layout I would think just a toggle for the base is fine so that it becomes a single entry. Mixed Layout A radio group of 3 entries: "Hide Base", "Show Base Top", "Show Base Center". Alternatively if we worry about too many entries, we could also do a submenu for "Base" specifically with these options.
Jo's suggestion in is also fine, but I think we need that third entry to allow for hiding when in mixed layout.
Verification steps: Open a merge conflict and verify these menu entries: ! !

Discussion:
menu: [ { id: MenuId.EditorTitle, <del> when: ctxIsMergeEditor, </del> <ins> when: ContextKeyExpr.and(ctxIsMergeEditor, ctxMergeEditorLayout.isEqualTo('columns')), </ins> group: '2_merge', order: 9, }, <del> ], precondition: ctxIsMergeEditor, </del> <ins> ] </ins> }); }

} } <del> export class ShowHideAtTopBase extends Action2 { </del> <ins> export class ShowHideTopBase extends Action2 { </ins> constructor() { super({ <del> id: 'merge.showBaseAtTop', </del> <ins> id: 'merge.showBaseTop', </ins> title: { <del> value: localize('layout.showBaseAtTop', 'Show Base At Top'), original: 'Show Base At Top', </del> <ins> value: localize('layout.showBaseTop', 'Show Base Top'), original: 'Show Base Top', </ins> }, <del> toggled: ctxMergeEditorShowBaseAtTop.isEqualTo(true), </del> <ins> toggled: ContextKeyExpr.and(ctxMergeEditorShowBase, ctxMergeEditorShowBaseAtTop), </ins> menu: [ { id: MenuId.EditorTitle, <del> when: ctxIsMergeEditor, </del> <ins> when: ContextKeyExpr.and(ctxIsMergeEditor, ctxMergeEditorLayout.isEqualTo('mixed')), </ins> group: '2_merge', order: 10, }, ], <del> precondition: ContextKeyExpr.and(ctxIsMergeEditor, ctxMergeEditorShowBase, ctxMergeEditorLayout.isEqualTo('mixed')), </del> }); } run(accessor: ServicesAccessor): void { const { activeEditorPane } = accessor.get(IEditorService); if (activeEditorPane instanceof MergeEditor) { <del> activeEditorPane.toggleShowBaseAtTop(); </del> <ins> activeEditorPane.toggleShowBaseTop(); } } } export class ShowHideCenterBase extends Action2 { constructor() { super({ id: 'merge.showBaseCenter', title: { value: localize('layout.showBaseCenter', 'Show Base Center'), original: 'Show Base Center', }, toggled: ContextKeyExpr.and(ctxMergeEditorShowBase, ctxMergeEditorShowBaseAtTop.negate()), menu: [ { id: MenuId.EditorTitle, when: ContextKeyExpr.and(ctxIsMergeEditor, ctxMergeEditorLayout.isEqualTo('mixed')), group: '2_merge', order: 11, }, ], }); } run(accessor: ServicesAccessor): void { const { activeEditorPane } = accessor.get(IEditorService); if (activeEditorPane instanceof MergeEditor) { activeEditorPane.toggleShowBaseCenter(); </ins> } } }

import { EditorPaneDescriptor, IEditorPaneRegistry } from 'vs/workbench/browser/editor'; import { Extensions as WorkbenchExtensions, IWorkbenchContributionsRegistry } from 'vs/workbench/common/contributions'; import { EditorExtensions, IEditorFactoryRegistry } from 'vs/workbench/common/editor'; <del> import { AcceptAllInput1, AcceptAllInput2, AcceptMerge, CompareInput1WithBaseCommand, CompareInput2WithBaseCommand, GoToNextUnhandledConflict, GoToPreviousUnhandledConflict, OpenBaseFile, OpenMergeEditor, OpenResultResource, ResetToBaseAndAutoMergeCommand, SetColumnLayout, SetMixedLayout, ShowHideAtTopBase, ShowHideBase, ShowNonConflictingChanges, ToggleActiveConflictInput1, ToggleActiveConflictInput2 } from 'vs/workbench/contrib/mergeEditor/browser/commands/commands'; </del> <ins> import { AcceptAllInput1, AcceptAllInput2, AcceptMerge, CompareInput1WithBaseCommand, CompareInput2WithBaseCommand, GoToNextUnhandledConflict, GoToPreviousUnhandledConflict, OpenBaseFile, OpenMergeEditor, OpenResultResource, ResetToBaseAndAutoMergeCommand, SetColumnLayout, SetMixedLayout, ShowHideTopBase, ShowHideCenterBase, ShowHideBase, ShowNonConflictingChanges, ToggleActiveConflictInput1, ToggleActiveConflictInput2 } from 'vs/workbench/contrib/mergeEditor/browser/commands/commands'; </ins> import { MergeEditorCopyContentsToJSON, MergeEditorLoadContentsFromFolder, MergeEditorSaveContentsToFolder } from 'vs/workbench/contrib/mergeEditor/browser/commands/devCommands'; import { MergeEditorInput } from 'vs/workbench/contrib/mergeEditor/browser/mergeEditorInput'; import { MergeEditor, MergeEditorOpenHandlerContribution, MergeEditorResolverContribution } from 'vs/workbench/contrib/mergeEditor/browser/view/mergeEditor';

registerAction2(OpenResultResource); registerAction2(SetMixedLayout); registerAction2(SetColumnLayout); <del> registerAction2(ShowHideBase); registerAction2(ShowHideAtTopBase); </del> registerAction2(OpenMergeEditor); registerAction2(OpenBaseFile); registerAction2(ShowNonConflictingChanges); <ins> registerAction2(ShowHideBase); registerAction2(ShowHideTopBase); registerAction2(ShowHideCenterBase); </ins> registerAction2(GoToNextUnhandledConflict); registerAction2(GoToPreviousUnhandledConflict);

}); } <del> public toggleShowBaseAtTop(): void { </del> <ins> public toggleShowBaseTop(): void { const showBaseTop = this._layoutMode.value.showBase && this._layoutMode.value.showBaseAtTop; </ins> this.setLayout({ ...this._layoutMode.value, <del> showBaseAtTop: !this._layoutMode.value.showBaseAtTop, </del> <ins> showBaseAtTop: true, showBase: !showBaseTop, }); } public toggleShowBaseCenter(): void { const showBaseCenter = this._layoutMode.value.showBase && !this._layoutMode.value.showBaseAtTop; this.setLayout({ ...this._layoutMode.value, showBaseAtTop: false, showBase: !showBaseCenter, </ins> }); }