Skip to content

Commit e14e406

Browse files
authored
Merge pull request microsoft#182324 from microsoft/merogge/acc-edit
use `editMode:preview` by default for screen reader users
2 parents c0377b2 + c59162e commit e14e406

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/vs/workbench/contrib/interactiveEditor/browser/interactiveEditorController.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { IEditorWorkerService } from 'vs/editor/common/services/editorWorker';
2323
import { IModelService } from 'vs/editor/common/services/model';
2424
import { InlineCompletionsController } from 'vs/editor/contrib/inlineCompletions/browser/inlineCompletionsController';
2525
import { localize } from 'vs/nls';
26+
import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility';
2627
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
2728
import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
2829
import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
@@ -105,6 +106,7 @@ export class InteractiveEditorController implements IEditorContribution {
105106
@INotebookEditorService private readonly _notebookEditorService: INotebookEditorService,
106107
@IDialogService private readonly _dialogService: IDialogService,
107108
@IContextKeyService contextKeyService: IContextKeyService,
109+
@IAccessibilityService private readonly _accessibilityService: IAccessibilityService
108110
) {
109111
this._ctxHasActiveRequest = CTX_INTERACTIVE_EDITOR_HAS_ACTIVE_REQUEST.bindTo(contextKeyService);
110112
this._ctxLastEditKind = CTX_INTERACTIVE_EDITOR_LAST_EDIT_KIND.bindTo(contextKeyService);
@@ -137,6 +139,17 @@ export class InteractiveEditorController implements IEditorContribution {
137139
return INTERACTIVE_EDITOR_ID;
138140
}
139141

142+
private _getMode(): EditMode {
143+
let editMode: EditMode = this._configurationService.getValue('interactiveEditor.editMode');
144+
const isDefault = editMode === EditMode.LivePreview;
145+
if (this._accessibilityService.isScreenReaderOptimized() && isDefault) {
146+
// By default, use preview mode for screen reader users
147+
editMode = EditMode.Preview;
148+
this._configurationService.updateValue('interactiveEditor.editMode', EditMode.Preview);
149+
}
150+
return editMode;
151+
}
152+
140153
getWidgetPosition(): Position | undefined {
141154
return this._zone.position;
142155
}
@@ -171,7 +184,7 @@ export class InteractiveEditorController implements IEditorContribution {
171184

172185
session = await this._interactiveEditorSessionService.createSession(
173186
this._editor,
174-
{ editMode: this._configurationService.getValue('interactiveEditor.editMode'), wholeRange: options?.initialRange },
187+
{ editMode: this._getMode(), wholeRange: options?.initialRange },
175188
createSessionCts.token
176189
);
177190

0 commit comments

Comments
 (0)