Skip to content

Commit f4245ce

Browse files
authored
Merge pull request microsoft#153701 from microsoft/3wm
2 parents 1230b7c + b4a97a6 commit f4245ce

File tree

5 files changed

+37
-17
lines changed

5 files changed

+37
-17
lines changed

src/vs/workbench/contrib/mergeEditor/browser/commands/commands.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ import { URI, UriComponents } from 'vs/base/common/uri';
88
import { localize } from 'vs/nls';
99
import { Action2, MenuId } from 'vs/platform/actions/common/actions';
1010
import { ICommandService } from 'vs/platform/commands/common/commands';
11-
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
1211
import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
1312
import { API_OPEN_DIFF_EDITOR_COMMAND_ID } from 'vs/workbench/browser/parts/editor/editorCommands';
1413
import { MergeEditorInput, MergeEditorInputData } from 'vs/workbench/contrib/mergeEditor/browser/mergeEditorInput';
15-
import { ctxIsMergeEditor, ctxMergeEditorLayout, MergeEditor } from 'vs/workbench/contrib/mergeEditor/browser/view/mergeEditor';
14+
import { MergeEditor } from 'vs/workbench/contrib/mergeEditor/browser/view/mergeEditor';
15+
import { ctxMergeEditorLayout, ctxIsMergeEditor } from 'vs/workbench/contrib/mergeEditor/common/mergeEditor';
1616
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
1717

1818
export class OpenMergeEditor extends Action2 {
@@ -112,13 +112,14 @@ export class SetMixedLayout extends Action2 {
112112
super({
113113
id: 'merge.mixedLayout',
114114
title: localize('layout.mixed', "Mixed Layout"),
115-
toggled: ContextKeyExpr.equals(ctxMergeEditorLayout.key, 'mixed'),
115+
toggled: ctxMergeEditorLayout.isEqualTo('mixed'),
116116
menu: [{
117117
id: MenuId.EditorTitle,
118118
when: ctxIsMergeEditor,
119119
group: '1_merge',
120120
order: 9,
121-
}]
121+
}],
122+
precondition: ctxIsMergeEditor,
122123
});
123124
}
124125

@@ -135,13 +136,14 @@ export class SetColumnLayout extends Action2 {
135136
super({
136137
id: 'merge.columnLayout',
137138
title: localize('layout.column', "Column Layout"),
138-
toggled: ContextKeyExpr.equals(ctxMergeEditorLayout.key, 'columns'),
139+
toggled: ctxMergeEditorLayout.isEqualTo('columns'),
139140
menu: [{
140141
id: MenuId.EditorTitle,
141142
when: ctxIsMergeEditor,
142143
group: '1_merge',
143144
order: 10,
144-
}]
145+
}],
146+
precondition: ctxIsMergeEditor,
145147
});
146148
}
147149

@@ -166,6 +168,7 @@ export class GoToNextConflict extends Action2 {
166168
group: 'navigation',
167169
}],
168170
f1: true,
171+
precondition: ctxIsMergeEditor,
169172
});
170173
}
171174

@@ -190,6 +193,7 @@ export class GoToPreviousConflict extends Action2 {
190193
group: 'navigation',
191194
}],
192195
f1: true,
196+
precondition: ctxIsMergeEditor,
193197
});
194198
}
195199

@@ -208,6 +212,7 @@ export class ToggleActiveConflictInput1 extends Action2 {
208212
category: localize('mergeEditor', "Merge Editor"),
209213
title: localize('merge.toggleActiveConflictInput1', "Toggle Active Conflict In Input 1"),
210214
f1: true,
215+
precondition: ctxIsMergeEditor,
211216
});
212217
}
213218

@@ -230,6 +235,7 @@ export class ToggleActiveConflictInput2 extends Action2 {
230235
category: localize('mergeEditor', "Merge Editor"),
231236
title: localize('merge.toggleActiveConflictInput2', "Toggle Active Conflict In Input 2"),
232237
f1: true,
238+
precondition: ctxIsMergeEditor,
233239
});
234240
}
235241

@@ -252,6 +258,7 @@ export class CompareInput1WithBaseCommand extends Action2 {
252258
category: localize('mergeEditor', "Merge Editor"),
253259
title: localize('mergeEditor.compareInput1WithBase', "Compare Input 1 With Base"),
254260
f1: true,
261+
precondition: ctxIsMergeEditor,
255262
});
256263
}
257264
run(accessor: ServicesAccessor, ...args: unknown[]): void {
@@ -268,6 +275,7 @@ export class CompareInput2WithBaseCommand extends Action2 {
268275
category: localize('mergeEditor', "Merge Editor"),
269276
title: localize('mergeEditor.compareInput2WithBase', "Compare Input 2 With Base"),
270277
f1: true,
278+
precondition: ctxIsMergeEditor,
271279
});
272280
}
273281
run(accessor: ServicesAccessor, ...args: unknown[]): void {

src/vs/workbench/contrib/mergeEditor/browser/commands/devCommands.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { IEditorService } from 'vs/workbench/services/editor/common/editorServic
1818
import { IWorkbenchFileService } from 'vs/workbench/services/files/common/files';
1919
import { URI } from 'vs/base/common/uri';
2020
import { MergeEditorInput } from 'vs/workbench/contrib/mergeEditor/browser/mergeEditorInput';
21+
import { ctxIsMergeEditor } from 'vs/workbench/contrib/mergeEditor/common/mergeEditor';
2122

2223
interface MergeEditorContents {
2324
languageId: string;
@@ -32,9 +33,11 @@ export class MergeEditorCopyContentsToJSON extends Action2 {
3233
constructor() {
3334
super({
3435
id: 'merge.dev.copyContents',
35-
title: localize('merge.dev.copyContents', "Developer Merge Editor: Copy Contents of Inputs, Base and Result as JSON"),
36+
category: 'Merge Editor (Dev)',
37+
title: localize('merge.dev.copyContents', "Copy Contents of Inputs, Base and Result as JSON"),
3638
icon: Codicon.layoutCentered,
3739
f1: true,
40+
precondition: ctxIsMergeEditor,
3841
});
3942
}
4043

@@ -76,7 +79,8 @@ export class MergeEditorOpenContents extends Action2 {
7679
constructor() {
7780
super({
7881
id: 'merge.dev.openContents',
79-
title: localize('merge.dev.openContents', "Developer Merge Editor: Open Contents of Inputs, Base and Result from JSON"),
82+
category: 'Merge Editor (Dev)',
83+
title: localize('merge.dev.openContents', "Open Contents of Inputs, Base and Result from JSON"),
8084
icon: Codicon.layoutCentered,
8185
f1: true,
8286
});

src/vs/workbench/contrib/mergeEditor/browser/view/mergeEditor.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { localize } from 'vs/nls';
2323
import { createAndFillInActionBarActions } from 'vs/platform/actions/browser/menuEntryActionViewItem';
2424
import { IMenuService, MenuId } from 'vs/platform/actions/common/actions';
2525
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
26-
import { IContextKey, IContextKeyService, RawContextKey } from 'vs/platform/contextkey/common/contextkey';
26+
import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
2727
import { IEditorOptions, ITextEditorOptions } from 'vs/platform/editor/common/editor';
2828
import { IFileService } from 'vs/platform/files/common/files';
2929
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
@@ -42,6 +42,7 @@ import { DocumentMapping, getOppositeDirection, MappingDirection } from 'vs/work
4242
import { MergeEditorModel } from 'vs/workbench/contrib/mergeEditor/browser/model/mergeEditorModel';
4343
import { deepMerge, ReentrancyBarrier, thenIfNotDisposed } from 'vs/workbench/contrib/mergeEditor/browser/utils';
4444
import { MergeEditorViewModel } from 'vs/workbench/contrib/mergeEditor/browser/view/viewModel';
45+
import { ctxBaseResourceScheme, ctxIsMergeEditor, ctxMergeEditorLayout, MergeEditorLayoutTypes } from 'vs/workbench/contrib/mergeEditor/common/mergeEditor';
4546
import { settingsSashBorder } from 'vs/workbench/contrib/preferences/common/settingsEditorColorRegistry';
4647
import { IEditorGroup, IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
4748
import { IEditorResolverService, RegisteredEditorPriority } from 'vs/workbench/services/editor/common/editorResolverService';
@@ -50,12 +51,6 @@ import './colors';
5051
import { InputCodeEditorView } from './editors/inputCodeEditorView';
5152
import { ResultCodeEditorView } from './editors/resultCodeEditorView';
5253

53-
export const ctxIsMergeEditor = new RawContextKey<boolean>('isMergeEditor', false);
54-
export const ctxMergeEditorLayout = new RawContextKey<MergeEditorLayoutTypes>('mergeEditorLayout', 'mixed');
55-
export const ctxBaseResourceScheme = new RawContextKey<string>('baseResourceScheme', '');
56-
57-
export type MergeEditorLayoutTypes = 'mixed' | 'columns';
58-
5954
class MergeEditorLayout {
6055

6156
private static readonly _key = 'mergeEditor/layout';
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
import { RawContextKey } from 'vs/platform/contextkey/common/contextkey';
7+
8+
export type MergeEditorLayoutTypes = 'mixed' | 'columns';
9+
10+
export const ctxIsMergeEditor = new RawContextKey<boolean>('isMergeEditor', false);
11+
export const ctxMergeEditorLayout = new RawContextKey<MergeEditorLayoutTypes>('mergeEditorLayout', 'mixed');
12+
export const ctxBaseResourceScheme = new RawContextKey<string>('baseResourceScheme', '');

src/vs/workbench/contrib/userDataSync/browser/userDataSync.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { localize } from 'vs/nls';
1818
import { MenuId, MenuRegistry, registerAction2, Action2 } from 'vs/platform/actions/common/actions';
1919
import { CommandsRegistry, ICommandService } from 'vs/platform/commands/common/commands';
2020
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
21-
import { ContextKeyDefinedExpr, ContextKeyEqualsExpr, ContextKeyExpr, IContextKey, IContextKeyService, RawContextKey } from 'vs/platform/contextkey/common/contextkey';
21+
import { ContextKeyEqualsExpr, ContextKeyExpr, IContextKey, IContextKeyService, RawContextKey } from 'vs/platform/contextkey/common/contextkey';
2222
import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
2323
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
2424
import { INotificationService, Severity } from 'vs/platform/notification/common/notification';
@@ -59,6 +59,7 @@ import { IHostService } from 'vs/workbench/services/host/browser/host';
5959
import { IUserDataProfilesService } from 'vs/platform/userDataProfile/common/userDataProfile';
6060
import { MergeEditorInput } from 'vs/workbench/contrib/mergeEditor/browser/mergeEditorInput';
6161
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
62+
import { ctxIsMergeEditor } from 'vs/workbench/contrib/mergeEditor/common/mergeEditor';
6263

6364
const CONTEXT_CONFLICTS_SOURCES = new RawContextKey<string>('conflictsSources', '');
6465

@@ -1290,7 +1291,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
12901291
title: localize('accept merges title', "Accept Merge"),
12911292
menu: [{
12921293
id: MenuId.MergeToolbar,
1293-
when: ContextKeyExpr.and(ContextKeyDefinedExpr.create('isMergeEditor'), ContextKeyEqualsExpr.create('baseResourceScheme', USER_DATA_SYNC_SCHEME)),
1294+
when: ContextKeyExpr.and(ctxIsMergeEditor, ContextKeyEqualsExpr.create('baseResourceScheme', USER_DATA_SYNC_SCHEME)),
12941295
}],
12951296
});
12961297
}

0 commit comments

Comments
 (0)