Skip to content

Commit 3747d22

Browse files
authored
Merge pull request microsoft#163677 from microsoft/tyriar/161622
Defer updating screen reader content when no in a11y mode
2 parents 3019960 + 410f9ce commit 3747d22

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import { MOUSE_CURSOR_TEXT_CSS_CLASS_NAME } from 'vs/base/browser/ui/mouseCursor
3434
import { TokenizationRegistry } from 'vs/editor/common/languages';
3535
import { ColorId, ITokenPresentation } from 'vs/editor/common/encodedTokenAttributes';
3636
import { Color } from 'vs/base/common/color';
37+
import { TimeoutTimer } from 'vs/base/common/async';
3738

3839
export interface IVisibleRangeProvider {
3940
visibleRangeForPosition(position: Position): HorizontalPosition | null;
@@ -112,6 +113,7 @@ export class TextAreaHandler extends ViewPart {
112113

113114
private _accessibilitySupport!: AccessibilitySupport;
114115
private _accessibilityPageSize!: number;
116+
private _accessibilityWriteTimer: TimeoutTimer;
115117
private _contentLeft: number;
116118
private _contentWidth: number;
117119
private _contentHeight: number;
@@ -149,6 +151,7 @@ export class TextAreaHandler extends ViewPart {
149151
const layoutInfo = options.get(EditorOption.layoutInfo);
150152

151153
this._setAccessibilityOptions(options);
154+
this._accessibilityWriteTimer = this._register(new TimeoutTimer());
152155
this._contentLeft = layoutInfo.contentLeft;
153156
this._contentWidth = layoutInfo.contentWidth;
154157
this._contentHeight = layoutInfo.height;
@@ -575,7 +578,11 @@ export class TextAreaHandler extends ViewPart {
575578
public override onCursorStateChanged(e: viewEvents.ViewCursorStateChangedEvent): boolean {
576579
this._selections = e.selections.slice(0);
577580
this._modelSelections = e.modelSelections.slice(0);
578-
this._textAreaInput.writeScreenReaderContent('selection changed');
581+
if (this._accessibilitySupport === AccessibilitySupport.Disabled) {
582+
this._accessibilityWriteTimer.cancelAndSet(() => this._textAreaInput.writeScreenReaderContent('selection changed'), 0);
583+
} else {
584+
this._textAreaInput.writeScreenReaderContent('selection changed');
585+
}
579586
return true;
580587
}
581588
public override onDecorationsChanged(e: viewEvents.ViewDecorationsChangedEvent): boolean {

0 commit comments

Comments
 (0)