Skip to content

Commit 210f6d5

Browse files
authored
Add category to "Go to Next/Previous Difference" commands (microsoft#188292)
1 parent 2e615c0 commit 210f6d5

File tree

1 file changed

+26
-18
lines changed

1 file changed

+26
-18
lines changed

src/vs/editor/browser/widget/diffEditor.contribution.ts

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,59 +5,67 @@
55

66
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
77
import { ICodeEditor, IDiffEditor } from 'vs/editor/browser/editorBrowser';
8-
import { EditorAction, ServicesAccessor, registerEditorAction } from 'vs/editor/browser/editorExtensions';
8+
import { EditorAction2, ServicesAccessor } from 'vs/editor/browser/editorExtensions';
99
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
1010
import { localize } from 'vs/nls';
11+
import { ILocalizedString } from 'vs/platform/action/common/action';
12+
import { registerAction2 } from 'vs/platform/actions/common/actions';
1113
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
1214
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
1315

14-
export class DiffReviewNext extends EditorAction {
16+
17+
const accessibleDiffViewerCategory: ILocalizedString = {
18+
value: localize('accessibleDiffViewer', 'Accessible Diff Viewer'),
19+
original: 'Accessible Diff Viewer',
20+
};
21+
22+
export class DiffReviewNext extends EditorAction2 {
1523
public static id = 'editor.action.diffReview.next';
1624

1725
constructor() {
1826
super({
1927
id: DiffReviewNext.id,
20-
label: localize('editor.action.diffReview.next', "Go to Next Difference"),
21-
alias: 'Go to Next Difference',
28+
title: { value: localize('editor.action.diffReview.next', "Go to Next Difference"), original: 'Go to Next Difference' },
29+
category: accessibleDiffViewerCategory,
2230
precondition: ContextKeyExpr.has('isInDiffEditor'),
23-
kbOpts: {
24-
kbExpr: null,
31+
keybinding: {
2532
primary: KeyCode.F7,
2633
weight: KeybindingWeight.EditorContrib
27-
}
34+
},
35+
f1: true,
2836
});
2937
}
3038

31-
public run(accessor: ServicesAccessor, editor: ICodeEditor): void {
39+
public override runEditorCommand(accessor: ServicesAccessor, editor: ICodeEditor): void {
3240
const diffEditor = findFocusedDiffEditor(accessor);
3341
diffEditor?.diffReviewNext();
3442
}
3543
}
3644

37-
export class DiffReviewPrev extends EditorAction {
45+
export class DiffReviewPrev extends EditorAction2 {
3846
public static id = 'editor.action.diffReview.prev';
3947

4048
constructor() {
4149
super({
4250
id: DiffReviewPrev.id,
43-
label: localize('editor.action.diffReview.prev', "Go to Previous Difference"),
44-
alias: 'Go to Previous Difference',
51+
title: { value: localize('editor.action.diffReview.prev', "Go to Previous Difference"), original: 'Go to Previous Difference' },
52+
category: accessibleDiffViewerCategory,
4553
precondition: ContextKeyExpr.has('isInDiffEditor'),
46-
kbOpts: {
47-
kbExpr: null,
54+
keybinding: {
4855
primary: KeyMod.Shift | KeyCode.F7,
4956
weight: KeybindingWeight.EditorContrib
50-
}
57+
},
58+
f1: true,
5159
});
5260
}
5361

54-
public run(accessor: ServicesAccessor, editor: ICodeEditor): void {
62+
public override runEditorCommand(accessor: ServicesAccessor, editor: ICodeEditor): void {
5563
const diffEditor = findFocusedDiffEditor(accessor);
5664
diffEditor?.diffReviewPrev();
5765
}
5866
}
5967

60-
function findFocusedDiffEditor(accessor: ServicesAccessor): IDiffEditor | null {
68+
export function findFocusedDiffEditor(accessor: ServicesAccessor): IDiffEditor | null {
6169
const codeEditorService = accessor.get(ICodeEditorService);
6270
const diffEditors = codeEditorService.listDiffEditors();
6371
const activeCodeEditor = codeEditorService.getFocusedCodeEditor() ?? codeEditorService.getActiveCodeEditor();
@@ -74,5 +82,5 @@ function findFocusedDiffEditor(accessor: ServicesAccessor): IDiffEditor | null {
7482
return null;
7583
}
7684

77-
registerEditorAction(DiffReviewNext);
78-
registerEditorAction(DiffReviewPrev);
85+
registerAction2(DiffReviewNext);
86+
registerAction2(DiffReviewPrev);

0 commit comments

Comments
 (0)