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

fix wording, allow undefined to be returned #188405

Merged
merged 2 commits into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/vs/workbench/contrib/accessibility/browser/accessibleView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ export interface IAccessibleViewService {
show(provider: IAccessibleContentProvider): void;
next(): void;
previous(): void;
getOpenAriaHint(verbositySettingKey: AccessibilityVerbositySettingId): string;
/**
* If the setting is enabled, provides the open accessible view hint as a localized string.
* @param verbositySettingKey The setting key for the verbosity of the feature
*/
getOpenAriaHint(verbositySettingKey: AccessibilityVerbositySettingId): string | undefined;
}

export const enum AccessibleViewType {
Expand Down Expand Up @@ -275,11 +279,14 @@ export class AccessibleViewService extends Disposable implements IAccessibleView
previous(): void {
this._accessibleView?.previous();
}
getOpenAriaHint(verbositySettingKey: AccessibilityVerbositySettingId): string {
getOpenAriaHint(verbositySettingKey: AccessibilityVerbositySettingId): string | undefined {
if (!this._configurationService.getValue(verbositySettingKey)) {
return;
}
let hint = '';
const keybinding = this._keybindingService.lookupKeybinding(AccessibleViewAction.id)?.getAriaLabel();
if (this._configurationService.getValue(verbositySettingKey)) {
hint = keybinding ? localize('chatAccessibleViewHint', "Inspect the response in the accessible view with {0}", keybinding) : localize('chatAccessibleViewHintNoKb', "Inspect the response in the accessible view via the command Open Accessible View which is currently not triggerable via keybinding");
hint = keybinding ? localize('chatAccessibleViewHint', "Inspect this in the accessible view with {0}", keybinding) : localize('chatAccessibleViewHintNoKb', "Inspect this in the accessible view via the command Open Accessible View which is currently not triggerable via keybinding");
}
return hint;
}
Expand Down
8 changes: 4 additions & 4 deletions src/vs/workbench/contrib/chat/browser/chatListRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -553,18 +553,18 @@ export class ChatAccessibilityProvider implements IListAccessibilityProvider<Cha
}

private _getLabelWithCodeBlockCount(element: IChatResponseViewModel): string {
const accessibleViewHint = this._accessibleViewService.getOpenAriaHint(AccessibilityVerbositySettingId.Chat).trim();
const accessibleViewHint = this._accessibleViewService.getOpenAriaHint(AccessibilityVerbositySettingId.Chat);
let label: string = '';
const codeBlockCount = marked.lexer(element.response.value).filter(token => token.type === 'code')?.length ?? 0;
switch (codeBlockCount) {
case 0:
label = localize('noCodeBlocks', "{0} {1}", element.response.value, accessibleViewHint);
label = accessibleViewHint ? localize('noCodeBlocksHint', "{0} {1}", element.response.value, accessibleViewHint) : localize('noCodeBlocks', "{0}", element.response.value);
break;
case 1:
label = localize('singleCodeBlock', "1 code block: {0} {1}", element.response.value, accessibleViewHint);
label = accessibleViewHint ? localize('singleCodeBlockHint', "1 code block: {0} {1}", element.response.value, accessibleViewHint) : localize('singleCodeBlock', "1 code block: {0}", element.response.value);
break;
default:
label = localize('multiCodeBlock', "{0} code blocks: {1}", codeBlockCount, element.response.value, accessibleViewHint);
label = accessibleViewHint ? localize('multiCodeBlockHint', "{0} code blocks: {1}", codeBlockCount, element.response.value, accessibleViewHint) : localize('multiCodeBlock', "{0} code blocks", codeBlockCount, element.response.value);
break;
}
return label;
Expand Down