Skip to content

Commit

Permalink
Mac: Fixes #10921: Markdown editor: Fix custom arrow-key shortcuts fa…
Browse files Browse the repository at this point in the history
…il to register (#10922)
  • Loading branch information
personalizedrefrigerator authored Aug 23, 2024
1 parent 12a2602 commit c691fed
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ describe('normalizeAccelerator', () => {
['Z', { v6: 'z', v5: 'Z' }],
['Alt+A', { v6: 'Alt-a', v5: 'Alt-A' }],
['Shift+A', { v6: 'Shift-a', v5: 'Shift-A' }],
['Shift+Up', { v6: 'Shift-Up', v5: 'Shift-Up' }],
['Shift+Up', { v6: 'Shift-ArrowUp', v5: 'Shift-Up' }],
])(
'should convert single-letter key names to lowercase for CM6, keep case unchanged for CM5 (%j)',
(original, expected) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,17 @@ const normalizeAccelerator = (accelerator: string, editorVersion: CodeMirrorVers
const parts = command.split(/-(?!$)/);
let name = parts[parts.length - 1];

// In CodeMirror 6, an uppercase single-letter key name makes the editor
// require the shift key to activate the shortcut. If a key name like `Up`,
// however, `.toLowerCase` breaks the shortcut.
if (editorVersion === CodeMirrorVersion.CodeMirror6 && name.length === 1) {
name = name.toLowerCase();
if (editorVersion === CodeMirrorVersion.CodeMirror6) {
// In CodeMirror 6, an uppercase single-letter key name makes the editor
// require the shift key to activate the shortcut. If a key name like `Up`,
// however, `.toLowerCase` breaks the shortcut.
if (name.length === 1) {
name = name.toLowerCase();
}

if (['Up', 'Down', 'Left', 'Right'].includes(name)) {
name = `Arrow${name}`;
}
}

let alt, ctrl, shift, cmd;
Expand Down

0 comments on commit c691fed

Please sign in to comment.