diff --git a/e2e/playwright/app-header-tests.spec.ts b/e2e/playwright/app-header-tests.spec.ts index b05c113d8..9402886d3 100644 --- a/e2e/playwright/app-header-tests.spec.ts +++ b/e2e/playwright/app-header-tests.spec.ts @@ -22,13 +22,13 @@ test.describe('Electron app header tests', () => { let text switch (process.platform) { case 'darwin': - text = 'Commands⌘ K' + text = 'Commands⌘K' break case 'win32': - text = 'CommandsCtrl + K' + text = 'CommandsCtrl+K' break default: // 'linux' etc. - text = 'CommandsCtrl K' + text = 'CommandsCtrl+K' break } const commandsButton = page.getByRole('button', { name: 'Commands' }) diff --git a/src/lib/hotkeyWrapper.ts b/src/lib/hotkeyWrapper.ts index 53ac006a8..21a9ba5a9 100644 --- a/src/lib/hotkeyWrapper.ts +++ b/src/lib/hotkeyWrapper.ts @@ -47,9 +47,18 @@ export function hotkeyDisplay(hotkey: string, platform: Platform): string { const isMac = platform === 'macos' const isWindows = platform === 'windows' const meta = isWindows ? 'Win' : 'Meta' - const separator = isWindows ? ' + ' : ' ' + const outputSeparator = isMac ? '' : '+' const display = hotkey - .replaceAll('+', separator) + // Capitalize letters. We want Ctrl K, not Ctrl k, since Shift should be + // shown as a separate modifier. + .split('+') + .map((word) => { + if (word.length === 1 && LOWER_CASE_LETTER.test(word)) { + return word.toUpperCase() + } + return word + }) + .join(outputSeparator) // Collapse multiple spaces into one. .replaceAll(WHITESPACE, ' ') .replaceAll('mod', isMac ? '⌘' : 'Ctrl') @@ -63,16 +72,6 @@ export function hotkeyDisplay(hotkey: string, platform: Platform): string { // The correct arrow is ⇧ "UPWARDS WHITE ARROW" Unicode: U+21E7 .replaceAll('shift', isMac ? '⬆' : 'Shift') .replaceAll('alt', isMac ? '⌥' : 'Alt') - // Capitalize letters. We want Ctrl K, not Ctrl k, since Shift should be - // shown as a separate modifier. - .split(separator) - .map((word) => { - if (word.length === 1 && LOWER_CASE_LETTER.test(word)) { - return word.toUpperCase() - } - return word - }) - .join(separator) return display }