Skip to content

Commit d1177d5

Browse files
authored
Merge pull request microsoft#188294 from microsoft/merogge/screen-reader-message
inform screen reader user how to enter optimized mode in editor
2 parents 210f6d5 + 9a29bef commit d1177d5

File tree

4 files changed

+34
-7
lines changed

4 files changed

+34
-7
lines changed

src/vs/editor/browser/controller/textAreaHandler.ts

+22-2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import { TokenizationRegistry } from 'vs/editor/common/languages';
3535
import { ColorId, ITokenPresentation } from 'vs/editor/common/encodedTokenAttributes';
3636
import { Color } from 'vs/base/common/color';
3737
import { IME } from 'vs/base/common/ime';
38+
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
3839

3940
export interface IVisibleRangeProvider {
4041
visibleRangeForPosition(position: Position): HorizontalPosition | null;
@@ -140,7 +141,12 @@ export class TextAreaHandler extends ViewPart {
140141
public readonly textAreaCover: FastDomNode<HTMLElement>;
141142
private readonly _textAreaInput: TextAreaInput;
142143

143-
constructor(context: ViewContext, viewController: ViewController, visibleRangeProvider: IVisibleRangeProvider) {
144+
constructor(
145+
context: ViewContext,
146+
viewController: ViewController,
147+
visibleRangeProvider: IVisibleRangeProvider,
148+
@IKeybindingService private readonly _keybindingService: IKeybindingService
149+
) {
144150
super(context);
145151

146152
this._viewController = viewController;
@@ -553,7 +559,21 @@ export class TextAreaHandler extends ViewPart {
553559
private _getAriaLabel(options: IComputedEditorOptions): string {
554560
const accessibilitySupport = options.get(EditorOption.accessibilitySupport);
555561
if (accessibilitySupport === AccessibilitySupport.Disabled) {
556-
return nls.localize('accessibilityOffAriaLabel', "The editor is not accessible at this time. Press {0} for options.", platform.isLinux ? 'Shift+Alt+F1' : 'Alt+F1');
562+
563+
const toggleKeybindingLabel = this._keybindingService.lookupKeybinding('editor.action.toggleScreenReaderAccessibilityMode')?.getAriaLabel();
564+
const runCommandKeybindingLabel = this._keybindingService.lookupKeybinding('workbench.action.showCommands')?.getAriaLabel();
565+
const keybindingEditorKeybindingLabel = this._keybindingService.lookupKeybinding('workbench.action.openGlobalKeybindings')?.getAriaLabel();
566+
const editorNotAccessibleMessage = nls.localize('accessibilityModeOff', "The editor is not accessible at this time.");
567+
if (toggleKeybindingLabel) {
568+
return nls.localize('accessibilityOffAriaLabel', "{0} To enable screen reader optimized mode, use {1}", editorNotAccessibleMessage, toggleKeybindingLabel);
569+
} else if (runCommandKeybindingLabel) {
570+
return nls.localize('accessibilityOffAriaLabelNoKb', "{0} To enable screen reader optimized mode, open the quick pick with {1} and run the command Toggle Screen Reader Accessibility Mode, which is currently not triggerable via keyboard.", editorNotAccessibleMessage, runCommandKeybindingLabel);
571+
} else if (keybindingEditorKeybindingLabel) {
572+
return nls.localize('accessibilityOffAriaLabelNoKbs', "{0} Please assign a keybinding for the command Toggle Screen Reader Accessibility Mode by accessing the keybindings editor with {1} and run it.", editorNotAccessibleMessage, keybindingEditorKeybindingLabel);
573+
} else {
574+
// SOS
575+
return editorNotAccessibleMessage;
576+
}
557577
}
558578
return options.get(EditorOption.ariaLabel);
559579
}

src/vs/editor/browser/view.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ import { IMouseWheelEvent } from 'vs/base/browser/mouseEvent';
5454
import { WhitespaceOverlay } from 'vs/editor/browser/viewParts/whitespace/whitespace';
5555
import { GlyphMarginWidgets } from 'vs/editor/browser/viewParts/glyphMargin/glyphMargin';
5656
import { GlyphMarginLane } from 'vs/editor/common/model';
57+
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
5758

5859

5960
export interface IContentWidgetData {
@@ -106,7 +107,8 @@ export class View extends ViewEventHandler {
106107
colorTheme: IColorTheme,
107108
model: IViewModel,
108109
userInputEvents: ViewUserInputEvents,
109-
overflowWidgetsDomNode: HTMLElement | undefined
110+
overflowWidgetsDomNode: HTMLElement | undefined,
111+
@IInstantiationService private readonly _instantiationService: IInstantiationService
110112
) {
111113
super();
112114
this._selections = [new Selection(1, 1, 1, 1)];
@@ -123,7 +125,7 @@ export class View extends ViewEventHandler {
123125
this._viewParts = [];
124126

125127
// Keyboard handler
126-
this._textAreaHandler = new TextAreaHandler(this._context, viewController, this._createTextAreaHandlerHelper());
128+
this._textAreaHandler = this._instantiationService.createInstance(TextAreaHandler, this._context, viewController, this._createTextAreaHandlerHelper());
127129
this._viewParts.push(this._textAreaHandler);
128130

129131
// These two dom nodes must be constructed up front, since references are needed in the layout provider (scrolling & co.)

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -1853,7 +1853,8 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
18531853
this._themeService.getColorTheme(),
18541854
viewModel,
18551855
viewUserInputEvents,
1856-
this._overflowWidgetsDomNode
1856+
this._overflowWidgetsDomNode,
1857+
this._instantiationService
18571858
);
18581859

18591860
return [view, true];

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

+6-2
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,15 @@ class ToggleScreenReaderMode extends Action2 {
2222
id: 'editor.action.toggleScreenReaderAccessibilityMode',
2323
title: { value: nls.localize('toggleScreenReaderMode', "Toggle Screen Reader Accessibility Mode"), original: 'Toggle Screen Reader Accessibility Mode' },
2424
f1: true,
25-
keybinding: {
25+
keybinding: [{
2626
primary: KeyMod.CtrlCmd | KeyCode.KeyE,
2727
weight: KeybindingWeight.WorkbenchContrib + 10,
2828
when: accessibilityHelpIsShown
29-
}
29+
},
30+
{
31+
primary: KeyMod.Alt | KeyCode.F3,
32+
weight: KeybindingWeight.WorkbenchContrib + 10,
33+
}]
3034
});
3135
}
3236

0 commit comments

Comments
 (0)