Change shortcut separator to be + and no spaces
This commit is contained in:
@ -22,13 +22,13 @@ test.describe('Electron app header tests', () => {
|
|||||||
let text
|
let text
|
||||||
switch (process.platform) {
|
switch (process.platform) {
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
text = 'Commands⌘ K'
|
text = 'Commands⌘K'
|
||||||
break
|
break
|
||||||
case 'win32':
|
case 'win32':
|
||||||
text = 'CommandsCtrl + K'
|
text = 'CommandsCtrl+K'
|
||||||
break
|
break
|
||||||
default: // 'linux' etc.
|
default: // 'linux' etc.
|
||||||
text = 'CommandsCtrl K'
|
text = 'CommandsCtrl+K'
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
const commandsButton = page.getByRole('button', { name: 'Commands' })
|
const commandsButton = page.getByRole('button', { name: 'Commands' })
|
||||||
|
@ -47,9 +47,18 @@ export function hotkeyDisplay(hotkey: string, platform: Platform): string {
|
|||||||
const isMac = platform === 'macos'
|
const isMac = platform === 'macos'
|
||||||
const isWindows = platform === 'windows'
|
const isWindows = platform === 'windows'
|
||||||
const meta = isWindows ? 'Win' : 'Meta'
|
const meta = isWindows ? 'Win' : 'Meta'
|
||||||
const separator = isWindows ? ' + ' : ' '
|
const outputSeparator = isMac ? '' : '+'
|
||||||
const display = hotkey
|
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.
|
// Collapse multiple spaces into one.
|
||||||
.replaceAll(WHITESPACE, ' ')
|
.replaceAll(WHITESPACE, ' ')
|
||||||
.replaceAll('mod', isMac ? '⌘' : 'Ctrl')
|
.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
|
// The correct arrow is ⇧ "UPWARDS WHITE ARROW" Unicode: U+21E7
|
||||||
.replaceAll('shift', isMac ? '⬆' : 'Shift')
|
.replaceAll('shift', isMac ? '⬆' : 'Shift')
|
||||||
.replaceAll('alt', isMac ? '⌥' : 'Alt')
|
.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
|
return display
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user