Skip to content

Commit 4d9332c

Browse files
authored
Merge pull request microsoft#180719 from microsoft/merogge/option
add accessibility verbosity settings, use editor options
2 parents 9f31548 + 7c905c6 commit 4d9332c

File tree

10 files changed

+87
-7
lines changed

10 files changed

+87
-7
lines changed

build/lib/i18n.resources.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,10 @@
513513
{
514514
"name": "vs/workbench/services/localization",
515515
"project": "vscode-workbench"
516+
},
517+
{
518+
"name": "vs/workbench/contrib/accessibility",
519+
"project": "vscode-workbench"
516520
}
517521
]
518522
}

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

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
286286
renderOverviewRuler: true,
287287
diffWordWrap: 'inherit',
288288
diffAlgorithm: 'advanced',
289+
accessibilityVerbose: true
289290
});
290291

291292
if (typeof options.isInEmbeddedEditor !== 'undefined') {
@@ -1274,7 +1275,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
12741275
if (options.originalAriaLabel) {
12751276
result.ariaLabel = options.originalAriaLabel;
12761277
}
1277-
result.ariaLabel += ariaNavigationTip;
1278+
this._updateAriaLabel(result);
12781279
result.readOnly = !this._options.originalEditable;
12791280
result.dropIntoEditor = { enabled: !result.readOnly };
12801281
result.extraEditorClassName = 'original-in-monaco-diff-editor';
@@ -1287,12 +1288,22 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
12871288
};
12881289
}
12891290

1291+
private _updateAriaLabel(options: IEditorConstructionOptions): void {
1292+
let ariaLabel = options.ariaLabel;
1293+
if (this._options.accessibilityVerbose) {
1294+
ariaLabel += ariaNavigationTip;
1295+
} else if (ariaLabel) {
1296+
ariaLabel = ariaLabel.replaceAll(ariaNavigationTip, '');
1297+
}
1298+
options.ariaLabel = ariaLabel;
1299+
}
1300+
12901301
private _adjustOptionsForRightHandSide(options: Readonly<editorBrowser.IDiffEditorConstructionOptions>): IEditorConstructionOptions {
12911302
const result = this._adjustOptionsForSubEditor(options);
12921303
if (options.modifiedAriaLabel) {
12931304
result.ariaLabel = options.modifiedAriaLabel;
12941305
}
1295-
result.ariaLabel += ariaNavigationTip;
1306+
this._updateAriaLabel(result);
12961307
result.wordWrapOverride1 = this._options.diffWordWrap;
12971308
result.revealHorizontalRightPadding = EditorOptions.revealHorizontalRightPadding.defaultValue + DiffEditorWidget.ENTIRE_DIFF_OVERVIEW_WIDTH;
12981309
result.scrollbar!.verticalHasArrows = false;
@@ -2767,6 +2778,7 @@ function validateDiffEditorOptions(options: Readonly<IDiffEditorOptions>, defaul
27672778
renderOverviewRuler: validateBooleanOption(options.renderOverviewRuler, defaults.renderOverviewRuler),
27682779
diffWordWrap: validateDiffWordWrap(options.diffWordWrap, defaults.diffWordWrap),
27692780
diffAlgorithm: validateStringSetOption(options.diffAlgorithm, defaults.diffAlgorithm, ['legacy', 'advanced'], { 'smart': 'legacy', 'experimental': 'advanced' }),
2781+
accessibilityVerbose: validateBooleanOption(options.accessibilityVerbose, defaults.accessibilityVerbose),
27702782
};
27712783
}
27722784

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,11 @@ import { ThemeIcon } from 'vs/base/common/themables';
3030
import { Constants } from 'vs/base/common/uint';
3131
import { Codicon } from 'vs/base/common/codicons';
3232
import { registerIcon } from 'vs/platform/theme/common/iconRegistry';
33-
import { ILanguageIdCodec } from 'vs/editor/common/languages';
3433
import { ILanguageService } from 'vs/editor/common/languages/language';
35-
import { ILineChange } from 'vs/editor/common/diff/smartLinesDiffComputer';
3634
import { AudioCue, IAudioCueService } from 'vs/platform/audioCues/browser/audioCueService';
35+
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
36+
import { ILineChange } from 'vs/editor/common/diff/smartLinesDiffComputer';
37+
import { ILanguageIdCodec } from 'vs/editor/common/languages';
3738

3839
const DIFF_LINES_PADDING = 3;
3940

@@ -102,7 +103,8 @@ export class DiffReview extends Disposable {
102103
constructor(
103104
diffEditor: DiffEditorWidget,
104105
@ILanguageService private readonly _languageService: ILanguageService,
105-
@IAudioCueService private readonly _audioCueService: IAudioCueService
106+
@IAudioCueService private readonly _audioCueService: IAudioCueService,
107+
@IConfigurationService private readonly _configurationService: IConfigurationService
106108
) {
107109
super();
108110
this._diffEditor = diffEditor;
@@ -180,6 +182,11 @@ export class DiffReview extends Disposable {
180182
this.accept();
181183
}
182184
}));
185+
this._register(this._configurationService.onDidChangeConfiguration(e => {
186+
if (e.affectsConfiguration('accessibility.verbosity.diff-editor')) {
187+
this._diffEditor.updateOptions({ accessibilityVerbose: this._configurationService.getValue('accessibility.verbosity.diff-editor') });
188+
}
189+
}));
183190
this._diffs = [];
184191
this._currentDiff = null;
185192
}

src/vs/editor/common/config/editorOptions.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,11 @@ export interface IDiffEditorBaseOptions {
784784
* Diff Algorithm
785785
*/
786786
diffAlgorithm?: 'legacy' | 'advanced' | IDocumentDiffProvider;
787+
788+
/**
789+
* Whether the diff editor aria label should be verbose.
790+
*/
791+
accessibilityVerbose?: boolean;
787792
}
788793

789794
/**

src/vs/monaco.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3841,6 +3841,10 @@ declare namespace monaco.editor {
38413841
* Diff Algorithm
38423842
*/
38433843
diffAlgorithm?: 'legacy' | 'advanced' | IDocumentDiffProvider;
3844+
/**
3845+
* Whether the diff editor aria label should be verbose.
3846+
*/
3847+
accessibilityVerbose?: boolean;
38443848
}
38453849

38463850
/**
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
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 { registerAccessibilityConfiguration } from 'vs/workbench/contrib/accessibility/browser/accessibilityContribution';
7+
8+
registerAccessibilityConfiguration();
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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 { localize } from 'vs/nls';
7+
import { Extensions, IConfigurationNode, IConfigurationRegistry } from 'vs/platform/configuration/common/configurationRegistry';
8+
import { Registry } from 'vs/platform/registry/common/platform';
9+
10+
const configuration: IConfigurationNode = {
11+
id: 'accessibility',
12+
title: localize('accessibilityConfigurationTitle', "Accessibility"),
13+
type: 'object',
14+
properties: {
15+
'accessibility.verbosity.terminal': {
16+
description: localize('verbosity.terminal.description', 'Provide information about how to access the terminal accessibility help menu when the terminal is focused'),
17+
type: 'boolean',
18+
default: true,
19+
tags: ['accessibility']
20+
},
21+
'accessibility.verbosity.diff-editor': {
22+
description: localize('verbosity.diff-editor.description', 'Provide information about how to navigate changes in the diff editor when it is focused'),
23+
type: 'boolean',
24+
default: true,
25+
tags: ['accessibility']
26+
}
27+
}
28+
};
29+
30+
export function registerAccessibilityConfiguration() {
31+
const configurationRegistry = Registry.as<IConfigurationRegistry>(Extensions.Configuration);
32+
configurationRegistry.registerConfiguration(configuration);
33+
}

src/vs/workbench/contrib/notebook/browser/diff/diffComponents.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,8 @@ abstract class AbstractElementRenderer extends Disposable {
502502
dimension: {
503503
height: this.cell.layoutInfo.metadataHeight,
504504
width: this.cell.getComputedCellContainerWidth(this.notebookEditor.getLayoutInfo(), true, true)
505-
}
505+
},
506+
accessibilityVerbose: this.configurationService.getValue<boolean>('accessibility.verbosity.diff-editor') ?? false
506507
}, {
507508
originalEditor: getOptimizedNestedCodeEditorWidgetOptions(),
508509
modifiedEditor: getOptimizedNestedCodeEditorWidgetOptions()

src/vs/workbench/contrib/terminal/browser/terminalInstance.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,9 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
524524
});
525525

526526
this._register(this._configurationService.onDidChangeConfiguration(async e => {
527+
if (e.affectsConfiguration('accessibility.verbosity.terminal')) {
528+
this._setAriaLabel(this.xterm?.raw, this._instanceId, this.title);
529+
}
527530
if (e.affectsConfiguration('terminal.integrated')) {
528531
this.updateConfig();
529532
this.setVisible(this._isVisible);
@@ -1942,7 +1945,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
19421945
labelParts.push(nls.localize('terminalScreenReaderMode', "Run the command: Toggle Screen Reader Accessibility Mode for an optimized screen reader experience"));
19431946
}
19441947
const accessibilityHelpKeybinding = this._keybindingService.lookupKeybinding(TerminalCommandId.ShowTerminalAccessibilityHelp)?.getLabel();
1945-
if (accessibilityHelpKeybinding) {
1948+
if (this._configurationService.getValue('accessibility.verbosity.terminal') && accessibilityHelpKeybinding) {
19461949
labelParts.push(nls.localize('terminalHelpAriaLabel', "Use {0} for terminal accessibility help", accessibilityHelpKeybinding));
19471950
}
19481951
xterm.textarea.setAttribute('aria-label', labelParts.join('\n'));

src/vs/workbench/workbench.common.main.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,4 +362,7 @@ import 'vs/workbench/contrib/deprecatedExtensionMigrator/browser/deprecatedExten
362362
// Bracket Pair Colorizer 2 Telemetry
363363
import 'vs/workbench/contrib/bracketPairColorizer2Telemetry/browser/bracketPairColorizer2Telemetry.contribution';
364364

365+
// Accessibility
366+
import 'vs/workbench/contrib/accessibility/browser/accessibility.contribution';
367+
365368
//#endregion

0 commit comments

Comments
 (0)