Skip to content

Commit

Permalink
Bind Shift-Enter to insertNewlineAndIndent
Browse files Browse the repository at this point in the history
FIX: Bind Shift-Enter to the same command as Enter in the default keymap,
so that it doesn't do nothing when on an EditContext-supporting browser.

Closes codemirror/dev#1447
  • Loading branch information
marijnh committed Sep 26, 2024
1 parent d0c97ba commit 22d2119
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,7 @@ export const emacsStyleKeymap: readonly KeyBinding[] = [
/// - End: [`cursorLineBoundaryForward`](#commands.cursorLineBoundaryForward) ([`selectLineBoundaryForward`](#commands.selectLineBoundaryForward) with Shift)
/// - Ctrl-Home (Cmd-Home on macOS): [`cursorDocStart`](#commands.cursorDocStart) ([`selectDocStart`](#commands.selectDocStart) with Shift)
/// - Ctrl-End (Cmd-Home on macOS): [`cursorDocEnd`](#commands.cursorDocEnd) ([`selectDocEnd`](#commands.selectDocEnd) with Shift)
/// - Enter: [`insertNewlineAndIndent`](#commands.insertNewlineAndIndent)
/// - Enter and Shift-Enter: [`insertNewlineAndIndent`](#commands.insertNewlineAndIndent)
/// - Ctrl-a (Cmd-a on macOS): [`selectAll`](#commands.selectAll)
/// - Backspace: [`deleteCharBackward`](#commands.deleteCharBackward)
/// - Delete: [`deleteCharForward`](#commands.deleteCharForward)
Expand Down Expand Up @@ -952,7 +952,7 @@ export const standardKeymap: readonly KeyBinding[] = ([
{key: "End", run: cursorLineBoundaryForward, shift: selectLineBoundaryForward, preventDefault: true},
{key: "Mod-End", run: cursorDocEnd, shift: selectDocEnd},

{key: "Enter", run: insertNewlineAndIndent},
{key: "Enter", run: insertNewlineAndIndent, shift: insertNewlineAndIndent},

{key: "Mod-a", run: selectAll},

Expand Down

1 comment on commit 22d2119

@St1ggy
Copy link

@St1ggy St1ggy commented on 22d2119 Sep 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better to use insertNewlineKeepIndent here, because almost all online editors don't create a new paragraph by default when you press Shift+Enter

Please sign in to comment.