Merge pull request #191329 from microsoft/merogge/kb

get all keybindings to be correct in terminal help dialog
This commit is contained in:
Megan Rogge
2023-08-26 06:43:15 -07:00
committed by GitHub
2 changed files with 10 additions and 12 deletions
@@ -335,7 +335,7 @@ class AccessibleView extends Disposable {
}
}
this._currentContent = message + provider.provideContent() + readMoreLink + disableHelpHint + localize('exit-tip', '\n\nExit this dialog via the Escape key.');
this._currentContent = message + provider.provideContent() + readMoreLink + disableHelpHint + localize('exit-tip', '\nExit this dialog via the Escape key.');
this._updateContextKeys(provider, true);
this._getTextModel(URI.from({ path: `accessible-view-${provider.verbositySettingKey}`, scheme: 'accessible-view', fragment: this._currentContent })).then((model) => {
@@ -47,25 +47,23 @@ export class TerminalAccessibleContentProvider extends Disposable implements IAc
_xterm: Pick<IXtermTerminal, 'getFont' | 'shellIntegration'> & { raw: Terminal },
@IInstantiationService _instantiationService: IInstantiationService,
@IKeybindingService private readonly _keybindingService: IKeybindingService,
@IAccessibilityService private readonly _accessibilityService: IAccessibilityService,
@IContextKeyService private readonly _contextKeyService: IContextKeyService,
@ICommandService private readonly _commandService: ICommandService
@ICommandService private readonly _commandService: ICommandService,
@IAccessibilityService private readonly _accessibilityService: IAccessibilityService
) {
super();
this._hasShellIntegration = _xterm.shellIntegration.status === ShellIntegrationStatus.VSCode;
}
private _descriptionForCommand(commandId: string, msg: string, noKbMsg: string): string {
const kb = this._keybindingService.lookupKeybindings(commandId);
switch (kb.length) {
case 0:
return format(noKbMsg, commandId);
case 1:
return format(msg, kb[0].getAriaLabel());
if (commandId === TerminalCommandId.RunRecentCommand) {
const kb = this._keybindingService.lookupKeybindings(commandId);
// Run recent command has multiple keybindings. lookupKeybinding just returns the first one regardless of the when context.
// Thus, we have to check if accessibility mode is enabled to determine which keybinding to use.
return this._accessibilityService.isScreenReaderOptimized() ? format(msg, kb[1].getAriaLabel()) : format(msg, kb[0].getAriaLabel());
}
// Run recent command has multiple keybindings. lookupKeybinding just returns the first one regardless of the when context.
// Thus, we have to check if accessibility mode is enabled to determine which keybinding to use.
return this._accessibilityService.isScreenReaderOptimized() ? format(msg, kb[1].getAriaLabel()) : format(msg, kb[0].getAriaLabel());
const kb = this._keybindingService.lookupKeybinding(commandId, this._contextKeyService)?.getAriaLabel();
return !kb ? format(noKbMsg, commandId) : format(msg, kb);
}
provideContent(): string {