From 9caf8d7642e3a11e346b0290377c1664cf30ba27 Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Fri, 2 Jun 2017 11:35:21 +0200 Subject: [PATCH] Have other places respect `editor.accessibilitySupport` (#27833, #27893) --- .../contrib/gotoError/browser/gotoError.ts | 3 +- .../browser/parts/editor/editorStatus.ts | 30 +++++++++++++------ 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/src/vs/editor/contrib/gotoError/browser/gotoError.ts b/src/vs/editor/contrib/gotoError/browser/gotoError.ts index 69792d86b8e..d0e1a23068b 100644 --- a/src/vs/editor/contrib/gotoError/browser/gotoError.ts +++ b/src/vs/editor/contrib/gotoError/browser/gotoError.ts @@ -27,7 +27,6 @@ import { registerColor, oneOf } from 'vs/platform/theme/common/colorRegistry'; import { IThemeService, ITheme } from 'vs/platform/theme/common/themeService'; import { Color } from 'vs/base/common/color'; import { EditorContextKeys } from 'vs/editor/common/editorContextKeys'; -import { getAccessibilitySupport } from 'vs/base/browser/browser'; import { AccessibilitySupport } from 'vs/base/common/platform'; import { editorErrorForeground, editorErrorBorder, editorWarningForeground, editorWarningBorder } from 'vs/editor/common/view/editorColorRegistry'; @@ -279,7 +278,7 @@ class MarkerNavigationWidget extends ZoneWidget { public show(where: Position, heightInLines: number): void { super.show(where, heightInLines); - if (getAccessibilitySupport() !== AccessibilitySupport.Disabled) { + if (this.editor.getConfiguration().accessibilitySupport !== AccessibilitySupport.Disabled) { this.focus(); } } diff --git a/src/vs/workbench/browser/parts/editor/editorStatus.ts b/src/vs/workbench/browser/parts/editor/editorStatus.ts index 831f6897471..d17d44c54d9 100644 --- a/src/vs/workbench/browser/parts/editor/editorStatus.ts +++ b/src/vs/workbench/browser/parts/editor/editorStatus.ts @@ -14,7 +14,6 @@ import paths = require('vs/base/common/paths'); import types = require('vs/base/common/types'); import uri from 'vs/base/common/uri'; import errors = require('vs/base/common/errors'); -import * as browser from 'vs/base/browser/browser'; import { IStatusbarItem } from 'vs/workbench/browser/parts/statusbar/statusbar'; import { Action } from 'vs/base/common/actions'; import { language, LANGUAGE_DEFAULT, AccessibilitySupport } from 'vs/base/common/platform'; @@ -47,6 +46,7 @@ import { ITextFileService } from 'vs/workbench/services/textfile/common/textfile import { getCodeEditor as getEditorWidget } from 'vs/editor/common/services/codeEditorService'; import { IPreferencesService } from 'vs/workbench/parts/preferences/common/preferences'; import { ICursorPositionChangedEvent } from 'vs/editor/common/controller/cursorEvents'; +import { IConfigurationChangedEvent } from "vs/editor/common/config/editorOptions"; function toEditorWithEncodingSupport(input: IEditorInput): IEncodingSupport { if (input instanceof SideBySideEditorInput) { @@ -329,9 +329,7 @@ export class EditorStatus implements IStatusbarItem { this.untitledEditorService.onDidChangeEncoding(r => this.onResourceEncodingChange(r)), this.textFileService.models.onModelEncodingChanged(e => this.onResourceEncodingChange(e.resource)), TabFocus.onDidChangeTabFocus(e => this.onTabFocusModeChange()), - browser.onDidChangeAccessibilitySupport(() => this.onScreenReaderModeChange()) ); - this.onScreenReaderModeChange(); return combinedDisposable(this.toDispose); } @@ -492,6 +490,7 @@ export class EditorStatus implements IStatusbarItem { const control = getEditorWidget(activeEditor); // Update all states + this.onScreenReaderModeChange(control); this.onSelectionChange(control); this.onModeChange(control); this.onEOLChange(control); @@ -505,6 +504,13 @@ export class EditorStatus implements IStatusbarItem { // Attach new listeners to active editor if (control) { + // Hook Listener for Configuration changes + this.activeEditorListeners.push(control.onDidChangeConfiguration((event: IConfigurationChangedEvent) => { + if (event.accessibilitySupport) { + this.onScreenReaderModeChange(control); + } + })); + // Hook Listener for Selection changes this.activeEditorListeners.push(control.onDidChangeCursorPosition((event: ICursorPositionChangedEvent) => { this.onSelectionChange(control); @@ -595,6 +601,18 @@ export class EditorStatus implements IStatusbarItem { this.updateState(update); } + private onScreenReaderModeChange(editorWidget: ICommonCodeEditor): void { + let screenReaderMode = false; + + // We only support text based editors + if (editorWidget) { + + screenReaderMode = (editorWidget.getConfiguration().accessibilitySupport === AccessibilitySupport.Enabled); + } + + this.updateState({ screenReaderMode: screenReaderMode }); + } + private onSelectionChange(editorWidget: ICommonCodeEditor): void { const info: IEditorSelectionStatus = {}; @@ -685,12 +703,6 @@ export class EditorStatus implements IStatusbarItem { this.updateState(info); } - private onScreenReaderModeChange(): void { - const info: StateDelta = { screenReaderMode: browser.getAccessibilitySupport() === AccessibilitySupport.Enabled }; - - this.updateState(info); - } - private isActiveEditor(e: IBaseEditor): boolean { const activeEditor = this.editorService.getActiveEditor(); -- GitLab