From 835be78328a03b492443a83b4faf4fef59c178db Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Fri, 2 Jun 2017 11:18:55 +0200 Subject: [PATCH] Have a good aria label when the editor has accessibility disabled (#27833) --- src/vs/editor/common/config/editorOptions.ts | 36 +++++++++----------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/src/vs/editor/common/config/editorOptions.ts b/src/vs/editor/common/config/editorOptions.ts index 5db649e062c76..2daf0ddac8f2e 100644 --- a/src/vs/editor/common/config/editorOptions.ts +++ b/src/vs/editor/common/config/editorOptions.ts @@ -1634,11 +1634,9 @@ export class EditorOptionsValidator { */ export class InternalEditorOptionsFactory { - private static _handlePerformanceCritical(opts: IValidatedEditorOptions, performanceCritical: boolean): IValidatedEditorOptions { - if (!performanceCritical) { - return opts; - } - + private static _tweakValidatedOptions(opts: IValidatedEditorOptions, accessibilitySupport: platform.AccessibilitySupport): IValidatedEditorOptions { + const accessibilityIsOn = (accessibilitySupport === platform.AccessibilitySupport.Enabled); + const accessibilityIsOff = (accessibilitySupport === platform.AccessibilitySupport.Disabled); return { inDiffEditor: opts.inDiffEditor, wordSeparators: opts.wordSeparators, @@ -1666,14 +1664,14 @@ export class InternalEditorOptionsFactory { extraEditorClassName: opts.viewInfo.extraEditorClassName, disableMonospaceOptimizations: opts.viewInfo.disableMonospaceOptimizations, rulers: opts.viewInfo.rulers, - ariaLabel: opts.viewInfo.ariaLabel, + ariaLabel: (accessibilityIsOff ? nls.localize('accessibilityOffAriaLabel', "The editor is not accessible at this time. Press Alt+F1 for options.") : opts.viewInfo.ariaLabel), renderLineNumbers: opts.viewInfo.renderLineNumbers, renderCustomLineNumbers: opts.viewInfo.renderCustomLineNumbers, renderRelativeLineNumbers: opts.viewInfo.renderRelativeLineNumbers, selectOnLineNumbers: opts.viewInfo.selectOnLineNumbers, glyphMargin: opts.viewInfo.glyphMargin, revealHorizontalRightPadding: opts.viewInfo.revealHorizontalRightPadding, - roundedSelection: false, // DISABLED + roundedSelection: (accessibilityIsOn ? false : opts.viewInfo.roundedSelection), // DISABLED WHEN SCREEN READER IS ATTACHED overviewRulerLanes: opts.viewInfo.overviewRulerLanes, overviewRulerBorder: opts.viewInfo.overviewRulerBorder, cursorBlinking: opts.viewInfo.cursorBlinking, @@ -1682,14 +1680,14 @@ export class InternalEditorOptionsFactory { hideCursorInOverviewRuler: opts.viewInfo.hideCursorInOverviewRuler, scrollBeyondLastLine: opts.viewInfo.scrollBeyondLastLine, stopRenderingLineAfter: opts.viewInfo.stopRenderingLineAfter, - renderWhitespace: 'none', // DISABLED - renderControlCharacters: false, // DISABLED - fontLigatures: false, // DISABLED - renderIndentGuides: false, // DISABLED - renderLineHighlight: 'none', // DISABLED + renderWhitespace: (accessibilityIsOn ? 'none' : opts.viewInfo.renderWhitespace), // DISABLED WHEN SCREEN READER IS ATTACHED + renderControlCharacters: (accessibilityIsOn ? false : opts.viewInfo.renderControlCharacters), // DISABLED WHEN SCREEN READER IS ATTACHED + fontLigatures: (accessibilityIsOn ? false : opts.viewInfo.fontLigatures), // DISABLED WHEN SCREEN READER IS ATTACHED + renderIndentGuides: (accessibilityIsOn ? false : opts.viewInfo.renderIndentGuides), // DISABLED WHEN SCREEN READER IS ATTACHED + renderLineHighlight: (accessibilityIsOn ? 'none' : opts.viewInfo.renderLineHighlight), // DISABLED WHEN SCREEN READER IS ATTACHED scrollbar: opts.viewInfo.scrollbar, minimap: { - enabled: false, // DISABLED + enabled: (accessibilityIsOn ? false : opts.viewInfo.minimap.enabled), // DISABLED WHEN SCREEN READER IS ATTACHED renderCharacters: opts.viewInfo.minimap.renderCharacters, maxColumn: opts.viewInfo.minimap.maxColumn }, @@ -1713,12 +1711,12 @@ export class InternalEditorOptionsFactory { wordBasedSuggestions: opts.contribInfo.wordBasedSuggestions, suggestFontSize: opts.contribInfo.suggestFontSize, suggestLineHeight: opts.contribInfo.suggestLineHeight, - selectionHighlight: false, // DISABLED - occurrencesHighlight: false, // DISABLED - codeLens: false, // DISABLED - folding: false, // DISABLED + selectionHighlight: (accessibilityIsOn ? false : opts.contribInfo.selectionHighlight), // DISABLED WHEN SCREEN READER IS ATTACHED + occurrencesHighlight: (accessibilityIsOn ? false : opts.contribInfo.occurrencesHighlight), // DISABLED WHEN SCREEN READER IS ATTACHED + codeLens: (accessibilityIsOn ? false : opts.contribInfo.codeLens), // DISABLED WHEN SCREEN READER IS ATTACHED + folding: (accessibilityIsOn ? false : opts.contribInfo.folding), // DISABLED WHEN SCREEN READER IS ATTACHED showFoldingControls: opts.contribInfo.showFoldingControls, - matchBrackets: false, // DISABLED + matchBrackets: (accessibilityIsOn ? false : opts.contribInfo.matchBrackets), // DISABLED WHEN SCREEN READER IS ATTACHED find: opts.contribInfo.find } }; @@ -1738,7 +1736,7 @@ export class InternalEditorOptionsFactory { // Disable some non critical features to get as best performance as possible // See https://github.com/Microsoft/vscode/issues/26730 - const opts = this._handlePerformanceCritical(_opts, (accessibilitySupport === platform.AccessibilitySupport.Enabled)); + const opts = this._tweakValidatedOptions(_opts, accessibilitySupport); let lineDecorationsWidth: number; if (typeof opts.lineDecorationsWidth === 'string' && /^\d+(\.\d+)?ch$/.test(opts.lineDecorationsWidth)) {