Skip to content

Commit

Permalink
Have a good aria label when the editor has accessibility disabled (#2…
Browse files Browse the repository at this point in the history
  • Loading branch information
alexdima committed Jun 2, 2017
1 parent 891adac commit 835be78
Showing 1 changed file with 17 additions and 19 deletions.
36 changes: 17 additions & 19 deletions src/vs/editor/common/config/editorOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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
},
Expand All @@ -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
}
};
Expand All @@ -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)) {
Expand Down

0 comments on commit 835be78

Please sign in to comment.