Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use editMode:preview by default for screen reader users #182324

Merged
merged 2 commits into from
May 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { IEditorWorkerService } from 'vs/editor/common/services/editorWorker';
import { IModelService } from 'vs/editor/common/services/model';
import { InlineCompletionsController } from 'vs/editor/contrib/inlineCompletions/browser/inlineCompletionsController';
import { localize } from 'vs/nls';
import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
Expand Down Expand Up @@ -102,6 +103,7 @@ export class InteractiveEditorController implements IEditorContribution {
@IModelService private readonly _modelService: IModelService,
@INotebookEditorService private readonly _notebookEditorService: INotebookEditorService,
@IContextKeyService contextKeyService: IContextKeyService,
@IAccessibilityService private readonly _accessibilityService: IAccessibilityService
) {
this._ctxHasActiveRequest = CTX_INTERACTIVE_EDITOR_HAS_ACTIVE_REQUEST.bindTo(contextKeyService);
this._ctxLastEditKind = CTX_INTERACTIVE_EDITOR_LAST_EDIT_KIND.bindTo(contextKeyService);
Expand Down Expand Up @@ -134,6 +136,17 @@ export class InteractiveEditorController implements IEditorContribution {
return INTERACTIVE_EDITOR_ID;
}

private _getMode(): EditMode {
let editMode: EditMode = this._configurationService.getValue('interactiveEditor.editMode');
const isDefault = editMode === EditMode.LivePreview;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better use IConfigurationService.inspect and look at IConfigurationValue#defaultValue and value. That avoid hardcoding the (current) default and it will account for the fact where users explicitly configure live preview to be their choice.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sample:

isCustomTitleFormat(): boolean {
const title = this.configurationService.inspect<string>(WindowSettingNames.title);
const titleSeparator = this.configurationService.inspect<string>(WindowSettingNames.titleSeparator);
return title.value !== title.defaultValue || titleSeparator.value !== titleSeparator.defaultValue;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will create a follow up PR

if (this._accessibilityService.isScreenReaderOptimized() && isDefault) {
// By default, use preview mode for screen reader users
editMode = EditMode.Preview;
this._configurationService.updateValue('interactiveEditor.editMode', EditMode.Preview);
}
return editMode;
}

getWidgetPosition(): Position | undefined {
return this._zone.position;
}
Expand Down Expand Up @@ -194,7 +207,7 @@ export class InteractiveEditorController implements IEditorContribution {

session = await this._interactiveEditorSessionService.createSession(
this._editor,
{ editMode: this._configurationService.getValue('interactiveEditor.editMode'), wholeRange: options?.initialRange },
{ editMode: this._getMode(), wholeRange: options?.initialRange },
createSessionCts.token
);

Expand Down
Loading