Skip to content

Commit 8d808bc

Browse files
authored
1 parent f20ae7a commit 8d808bc

File tree

10 files changed

+56
-35
lines changed

10 files changed

+56
-35
lines changed

src/vs/editor/browser/editorBrowser.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,9 +1263,9 @@ export interface IDiffEditor extends editorCommon.IEditor {
12631263
*/
12641264
revealFirstDiff(): unknown;
12651265

1266-
diffReviewNext(): void;
1266+
accessibleDiffViewerNext(): void;
12671267

1268-
diffReviewPrev(): void;
1268+
accessibleDiffViewerPrev(): void;
12691269
}
12701270

12711271
/**

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

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,26 @@ import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
77
import { ICodeEditor, IDiffEditor } from 'vs/editor/browser/editorBrowser';
88
import { EditorAction2, ServicesAccessor } from 'vs/editor/browser/editorExtensions';
99
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
10+
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
1011
import { localize } from 'vs/nls';
1112
import { ILocalizedString } from 'vs/platform/action/common/action';
12-
import { registerAction2 } from 'vs/platform/actions/common/actions';
13+
import { MenuId, MenuRegistry, registerAction2 } from 'vs/platform/actions/common/actions';
14+
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
1315
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
1416
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
1517

16-
1718
const accessibleDiffViewerCategory: ILocalizedString = {
1819
value: localize('accessibleDiffViewer', 'Accessible Diff Viewer'),
1920
original: 'Accessible Diff Viewer',
2021
};
2122

22-
export class DiffReviewNext extends EditorAction2 {
23-
public static id = 'editor.action.diffReview.next';
23+
export class AccessibleDiffViewerNext extends EditorAction2 {
24+
public static id = 'editor.action.accessibleDiffViewer.next';
2425

2526
constructor() {
2627
super({
27-
id: DiffReviewNext.id,
28-
title: { value: localize('editor.action.diffReview.next', "Go to Next Difference"), original: 'Go to Next Difference' },
28+
id: AccessibleDiffViewerNext.id,
29+
title: { value: localize('editor.action.accessibleDiffViewer.next', "Go to Next Difference"), original: 'Go to Next Difference' },
2930
category: accessibleDiffViewerCategory,
3031
precondition: ContextKeyExpr.has('isInDiffEditor'),
3132
keybinding: {
@@ -38,17 +39,27 @@ export class DiffReviewNext extends EditorAction2 {
3839

3940
public override runEditorCommand(accessor: ServicesAccessor, editor: ICodeEditor): void {
4041
const diffEditor = findFocusedDiffEditor(accessor);
41-
diffEditor?.diffReviewNext();
42+
diffEditor?.accessibleDiffViewerNext();
4243
}
4344
}
4445

45-
export class DiffReviewPrev extends EditorAction2 {
46-
public static id = 'editor.action.diffReview.prev';
46+
MenuRegistry.appendMenuItem(MenuId.EditorTitle, {
47+
command: {
48+
id: AccessibleDiffViewerNext.id,
49+
title: localize('Open Accessible Diff Viewer', "Open Accessible Diff Viewer"),
50+
},
51+
order: 10,
52+
group: '2_diff',
53+
when: EditorContextKeys.accessibleDiffViewerVisible.negate(),
54+
});
55+
56+
export class AccessibleDiffViewerPrev extends EditorAction2 {
57+
public static id = 'editor.action.accessibleDiffViewer.prev';
4758

4859
constructor() {
4960
super({
50-
id: DiffReviewPrev.id,
51-
title: { value: localize('editor.action.diffReview.prev', "Go to Previous Difference"), original: 'Go to Previous Difference' },
61+
id: AccessibleDiffViewerPrev.id,
62+
title: { value: localize('editor.action.accessibleDiffViewer.prev', "Go to Previous Difference"), original: 'Go to Previous Difference' },
5263
category: accessibleDiffViewerCategory,
5364
precondition: ContextKeyExpr.has('isInDiffEditor'),
5465
keybinding: {
@@ -61,7 +72,7 @@ export class DiffReviewPrev extends EditorAction2 {
6172

6273
public override runEditorCommand(accessor: ServicesAccessor, editor: ICodeEditor): void {
6374
const diffEditor = findFocusedDiffEditor(accessor);
64-
diffEditor?.diffReviewPrev();
75+
diffEditor?.accessibleDiffViewerPrev();
6576
}
6677
}
6778

@@ -82,5 +93,8 @@ export function findFocusedDiffEditor(accessor: ServicesAccessor): IDiffEditor |
8293
return null;
8394
}
8495

85-
registerAction2(DiffReviewNext);
86-
registerAction2(DiffReviewPrev);
96+
CommandsRegistry.registerCommandAlias('editor.action.diffReview.next', AccessibleDiffViewerNext.id);
97+
registerAction2(AccessibleDiffViewerNext);
98+
99+
CommandsRegistry.registerCommandAlias('editor.action.diffReview.prev', AccessibleDiffViewerPrev.id);
100+
registerAction2(AccessibleDiffViewerPrev);

src/vs/editor/browser/widget/diffEditorWidget.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -445,11 +445,11 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
445445
return dom.isAncestor(document.activeElement, this._domElement);
446446
}
447447

448-
public diffReviewNext(): void {
448+
public accessibleDiffViewerNext(): void {
449449
this._reviewPane.next();
450450
}
451451

452-
public diffReviewPrev(): void {
452+
public accessibleDiffViewerPrev(): void {
453453
this._reviewPane.prev();
454454
}
455455

src/vs/editor/browser/widget/diffEditorWidget2/accessibleDiffViewer.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ import { AudioCue, IAudioCueService } from 'vs/platform/audioCues/browser/audioC
3535
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
3636
import { registerIcon } from 'vs/platform/theme/common/iconRegistry';
3737

38-
const diffReviewInsertIcon = registerIcon('diff-review-insert', Codicon.add, localize('diffReviewInsertIcon', 'Icon for \'Insert\' in diff review.'));
39-
const diffReviewRemoveIcon = registerIcon('diff-review-remove', Codicon.remove, localize('diffReviewRemoveIcon', 'Icon for \'Remove\' in diff review.'));
40-
const diffReviewCloseIcon = registerIcon('diff-review-close', Codicon.close, localize('diffReviewCloseIcon', 'Icon for \'Close\' in diff review.'));
38+
const accessibleDiffViewerInsertIcon = registerIcon('diff-review-insert', Codicon.add, localize('accessibleDiffViewerInsertIcon', 'Icon for \'Insert\' in accessible diff viewer.'));
39+
const accessibleDiffViewerRemoveIcon = registerIcon('diff-review-remove', Codicon.remove, localize('accessibleDiffViewerRemoveIcon', 'Icon for \'Remove\' in accessible diff viewer.'));
40+
const accessibleDiffViewerCloseIcon = registerIcon('diff-review-close', Codicon.close, localize('accessibleDiffViewerCloseIcon', 'Icon for \'Close\' in accessible diff viewer.'));
4141

4242
export class AccessibleDiffViewer extends Disposable {
4343
constructor(
@@ -345,7 +345,7 @@ class View extends Disposable {
345345
this._actionBar.push(new Action(
346346
'diffreview.close',
347347
localize('label.close', "Close"),
348-
'close-diff-review ' + ThemeIcon.asClassName(diffReviewCloseIcon),
348+
'close-diff-review ' + ThemeIcon.asClassName(accessibleDiffViewerCloseIcon),
349349
true,
350350
async () => _model.close()
351351
), { label: false, icon: true });
@@ -526,12 +526,12 @@ class View extends Disposable {
526526
case LineType.Added:
527527
rowClassName = 'diff-review-row line-insert';
528528
lineNumbersExtraClassName = ' char-insert';
529-
spacerIcon = diffReviewInsertIcon;
529+
spacerIcon = accessibleDiffViewerInsertIcon;
530530
break;
531531
case LineType.Deleted:
532532
rowClassName = 'diff-review-row line-delete';
533533
lineNumbersExtraClassName = ' char-delete';
534-
spacerIcon = diffReviewRemoveIcon;
534+
spacerIcon = accessibleDiffViewerRemoveIcon;
535535
break;
536536
}
537537

src/vs/editor/browser/widget/diffEditorWidget2/diffEditorWidget2.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@ export class DiffEditorWidget2 extends DelegatingEditor implements IDiffEditor {
103103
isEmbeddedDiffEditorKey.set(this._options.isInEmbeddedEditor.read(reader));
104104
}));
105105

106+
const accessibleDiffViewerVisibleContextKeyValue = EditorContextKeys.accessibleDiffViewerVisible.bindTo(this._contextKeyService);
107+
this._register(autorun('update accessibleDiffViewerVisible context key', reader => {
108+
accessibleDiffViewerVisibleContextKeyValue.set(this._accessibleDiffViewerVisible.read(reader));
109+
}));
110+
106111
this._domElement.appendChild(this.elements.root);
107112

108113
this._rootSizeObserver = this._register(new ObservableElementSizeObserver(this.elements.root, options.dimension));
@@ -472,9 +477,9 @@ export class DiffEditorWidget2 extends DelegatingEditor implements IDiffEditor {
472477
});
473478
}
474479

475-
diffReviewNext(): void { this._accessibleDiffViewer.next(); }
480+
accessibleDiffViewerNext(): void { this._accessibleDiffViewer.next(); }
476481

477-
diffReviewPrev(): void { this._accessibleDiffViewer.prev(); }
482+
accessibleDiffViewerPrev(): void { this._accessibleDiffViewer.prev(); }
478483

479484
async waitForDiff(): Promise<void> {
480485
const diffModel = this._diffModel.get();

src/vs/editor/common/editorContextKeys.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export namespace EditorContextKeys {
2727
export const readOnly = new RawContextKey<boolean>('editorReadonly', false, nls.localize('editorReadonly', "Whether the editor is read-only"));
2828
export const inDiffEditor = new RawContextKey<boolean>('inDiffEditor', false, nls.localize('inDiffEditor', "Whether the context is a diff editor"));
2929
export const isEmbeddedDiffEditor = new RawContextKey<boolean>('isEmbeddedDiffEditor', false, nls.localize('isEmbeddedDiffEditor', "Whether the context is an embedded diff editor"));
30+
export const accessibleDiffViewerVisible = new RawContextKey<boolean>('accessibleDiffViewerVisible', false, nls.localize('accessibleDiffViewerVisible', "Whether the accessible diff viewer is visible"));
3031
export const columnSelection = new RawContextKey<boolean>('editorColumnSelection', false, nls.localize('editorColumnSelection', "Whether `editor.columnSelection` is enabled"));
3132
export const writable = readOnly.toNegated();
3233
export const hasNonEmptySelection = new RawContextKey<boolean>('editorHasSelection', false, nls.localize('editorHasSelection', "Whether the editor has text selected"));

src/vs/monaco.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6133,8 +6133,8 @@ declare namespace monaco.editor {
61336133
* Update the editor's options after the editor has been created.
61346134
*/
61356135
updateOptions(newOptions: IDiffEditorOptions): void;
6136-
diffReviewNext(): void;
6137-
diffReviewPrev(): void;
6136+
accessibleDiffViewerNext(): void;
6137+
accessibleDiffViewerPrev(): void;
61386138
}
61396139

61406140
export class FontInfo extends BareFontInfo {

src/vs/workbench/contrib/audioCues/browser/audioCues.contribution.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,15 @@ Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration).regis
9898
...audioCueFeatureBase,
9999
},
100100
'audioCues.diffLineInserted': {
101-
'description': localize('audioCues.diffLineInserted', "Plays a sound when the focus moves to an inserted line in diff review mode or to the next/previous change"),
101+
'description': localize('audioCues.diffLineInserted', "Plays a sound when the focus moves to an inserted line in accessible diff viewer mode or to the next/previous change"),
102102
...audioCueFeatureBase,
103103
},
104104
'audioCues.diffLineDeleted': {
105-
'description': localize('audioCues.diffLineDeleted', "Plays a sound when the focus moves to a deleted line in diff review mode or to the next/previous change"),
105+
'description': localize('audioCues.diffLineDeleted', "Plays a sound when the focus moves to a deleted line in accessible diff viewer mode or to the next/previous change"),
106106
...audioCueFeatureBase,
107107
},
108108
'audioCues.diffLineModified': {
109-
'description': localize('audioCues.diffLineModified', "Plays a sound when the focus moves to a modified line in diff review mode or to the next/previous change"),
109+
'description': localize('audioCues.diffLineModified', "Plays a sound when the focus moves to a modified line in accessible diff viewer mode or to the next/previous change"),
110110
...audioCueFeatureBase,
111111
},
112112
'audioCues.notebookCellCompleted': {

src/vs/workbench/contrib/chat/browser/actions/chatAccessibilityHelp.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { IChatWidgetService } from 'vs/workbench/contrib/chat/browser/chat';
1313
import { InlineChatController } from 'vs/workbench/contrib/inlineChat/browser/inlineChatController';
1414
import { AccessibleViewType, IAccessibleViewService } from 'vs/workbench/contrib/accessibility/browser/accessibleView';
1515
import { AccessibilityVerbositySettingId } from 'vs/workbench/contrib/accessibility/browser/accessibilityContribution';
16+
import { AccessibleDiffViewerNext } from 'vs/editor/browser/widget/diffEditor.contribution';
1617

1718
export function getAccessibilityHelpText(accessor: ServicesAccessor, type: 'panelChat' | 'inlineChat'): string {
1819
const keybindingService = accessor.get(IKeybindingService);
@@ -36,7 +37,7 @@ export function getAccessibilityHelpText(accessor: ServicesAccessor, type: 'pane
3637
}
3738
content.push(localize('inlineChat.contextActions', "Context menu actions may run a request prefixed with a /. Type / to discover such ready-made commands."));
3839
content.push(localize('inlineChat.fix', "If a fix action is invoked, a response will indicate the problem with the current code. A diff editor will be rendered and can be reached by tabbing."));
39-
const diffReviewKeybinding = keybindingService.lookupKeybinding('editor.action.diffReview.next')?.getAriaLabel();
40+
const diffReviewKeybinding = keybindingService.lookupKeybinding(AccessibleDiffViewerNext.id)?.getAriaLabel();
4041
content.push(diffReviewKeybinding ? localize('inlineChat.diff', "Once in the diff editor, enter review mode with ({0}). Use up and down arrows to navigate lines with the proposed changes.", diffReviewKeybinding) : localize('inlineChat.diffNoKb', "Tab again to enter the Diff editor with the changes and enter review mode with the Go to Next Difference Command. Use Up/DownArrow to navigate lines with the proposed changes."));
4142
content.push(localize('inlineChat.toolbar', "Use tab to reach conditional parts like commands, status, message responses and more."));
4243
}

src/vs/workbench/contrib/codeEditor/browser/diffEditorHelper.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { Disposable, IDisposable } from 'vs/base/common/lifecycle';
77
import { IDiffEditor } from 'vs/editor/browser/editorBrowser';
88
import { registerDiffEditorContribution } from 'vs/editor/browser/editorExtensions';
99
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
10-
import { DiffReviewNext, DiffReviewPrev } from 'vs/editor/browser/widget/diffEditor.contribution';
10+
import { AccessibleDiffViewerNext, AccessibleDiffViewerPrev } from 'vs/editor/browser/widget/diffEditor.contribution';
1111
import { DiffEditorWidget2 } from 'vs/editor/browser/widget/diffEditorWidget2/diffEditorWidget2';
1212
import { EmbeddedDiffEditorWidget, EmbeddedDiffEditorWidget2 } from 'vs/editor/browser/widget/embeddedCodeEditorWidget';
1313
import { IDiffEditorContribution } from 'vs/editor/common/editorCommon';
@@ -86,8 +86,8 @@ function createScreenReaderHelp(): IDisposable {
8686
const codeEditorService = accessor.get(ICodeEditorService);
8787
const keybindingService = accessor.get(IKeybindingService);
8888

89-
const next = keybindingService.lookupKeybinding(DiffReviewNext.id)?.getAriaLabel();
90-
const previous = keybindingService.lookupKeybinding(DiffReviewPrev.id)?.getAriaLabel();
89+
const next = keybindingService.lookupKeybinding(AccessibleDiffViewerNext.id)?.getAriaLabel();
90+
const previous = keybindingService.lookupKeybinding(AccessibleDiffViewerPrev.id)?.getAriaLabel();
9191

9292
if (!(editorService.activeTextEditorControl instanceof DiffEditorWidget2)) {
9393
return;

0 commit comments

Comments
 (0)