mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-08 17:19:48 +01:00
or undefined
This commit is contained in:
@@ -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 {
|
||||
@@ -275,7 +279,10 @@ 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)) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user