Skip to content

Commit

Permalink
Desktop: Resolves #9980: Support Ctrl+Enter keyboard shortcut (Cmd+En…
Browse files Browse the repository at this point in the history
…ter on MacOS) (#10003)
  • Loading branch information
cagnusmarlsen authored Mar 2, 2024
1 parent ff1f1b1 commit c409160
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ export default function useKeymap(CodeMirror: any) {
'Alt-Right': 'goLineEnd',
'Ctrl-Backspace': 'delGroupBefore',
'Ctrl-Delete': 'delGroupAfter',
'Ctrl-Enter': 'insertLineAfter',

'fallthrough': 'basic',
};
Expand All @@ -167,6 +168,7 @@ export default function useKeymap(CodeMirror: any) {
'Alt-Backspace': 'delGroupBefore',
'Alt-Delete': 'delGroupAfter',
'Cmd-Backspace': 'delWrappedLineLeft',
'Cmd-Enter': 'insertLineAfter',

'fallthrough': 'basic',
};
Expand Down
5 changes: 5 additions & 0 deletions packages/editor/CodeMirror/createEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { selectionFormattingEqual } from '../SelectionFormatting';
import configFromSettings from './configFromSettings';
import getScrollFraction from './getScrollFraction';
import CodeMirrorControl from './CodeMirrorControl';
import insertLineAfter from './editorCommands/insertLineAfter';

const createEditor = (
parentElement: HTMLElement, props: EditorProps,
Expand Down Expand Up @@ -261,6 +262,10 @@ const createEditor = (
}),
keyCommand('Tab', insertOrIncreaseIndent, true),
keyCommand('Shift-Tab', decreaseIndent, true),
keyCommand('Mod-Enter', (_: EditorView) => {
insertLineAfter(_);
return true;
}, true),

...standardKeymap, ...historyKeymap, ...searchKeymap,
]),
Expand Down

0 comments on commit c409160

Please sign in to comment.