forked from microsoft/vscode
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
resolve accessibility help dialog kbs in
accessibleViewService
(mic…
- Loading branch information
1 parent
9e7a86c
commit 82348ce
Showing
8 changed files
with
102 additions
and
178 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/vs/workbench/contrib/accessibility/browser/accessibleViewKeybindingResolver.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import { MarkdownString } from 'vs/base/common/htmlContent'; | ||
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; | ||
import { IPickerQuickAccessItem } from 'vs/platform/quickinput/browser/pickerQuickAccess'; | ||
import { AccessibilityCommandId } from 'vs/workbench/contrib/accessibility/common/accessibilityCommands'; | ||
|
||
export function resolveContentAndKeybindingItems(keybindingService: IKeybindingService, value?: string): { content: MarkdownString; configureKeybindingItems: IPickerQuickAccessItem[] | undefined } | undefined { | ||
if (!value) { | ||
return; | ||
} | ||
const configureKeybindingItems: IPickerQuickAccessItem[] = []; | ||
const matches = value.matchAll(/\<keybinding:(?<commandId>.*)\>/gm); | ||
for (const match of [...matches]) { | ||
const commandId = match?.groups?.commandId; | ||
let kbLabel; | ||
if (match?.length && commandId) { | ||
const keybinding = keybindingService.lookupKeybinding(commandId)?.getAriaLabel(); | ||
if (!keybinding) { | ||
const configureKb = keybindingService.lookupKeybinding(AccessibilityCommandId.AccessibilityHelpConfigureKeybindings)?.getAriaLabel(); | ||
const keybindingToConfigureQuickPick = configureKb ? '(' + configureKb + ')' : 'by assigning a keybinding to the command Accessibility Help Configure Keybindings.'; | ||
kbLabel = `, configure a keybinding ` + keybindingToConfigureQuickPick; | ||
configureKeybindingItems.push({ | ||
label: commandId, | ||
id: commandId | ||
}); | ||
} else { | ||
kbLabel = ' (' + keybinding + ')'; | ||
} | ||
value = value.replace(match[0], kbLabel); | ||
} | ||
} | ||
const content = new MarkdownString(value); | ||
content.isTrusted = true; | ||
return { content, configureKeybindingItems: configureKeybindingItems.length ? configureKeybindingItems : undefined }; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.