Skip to content

Commit

Permalink
Fix Enter for vim mode (#1146)
Browse files Browse the repository at this point in the history
This is a workaround for replit/codemirror-vim#182

Fixes #1145 (harder)
  • Loading branch information
lutzky authored Nov 11, 2024
1 parent 4457927 commit 916c84e
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion web/editor_state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import customMarkdownStyle from "./style.ts";
import {
history,
indentWithTab,
insertNewlineAndIndent,
isolateHistory,
standardKeymap,
} from "@codemirror/commands";
Expand Down Expand Up @@ -367,7 +368,18 @@ export function createKeyBindings(client: Client): Extension {
...createCommandKeyBindings(client),
...createSmartQuoteKeyBindings(client),
...closeBracketsKeymap,
...client.ui.viewState.uiOptions.vimMode ? [] : standardKeymap,
...client.ui.viewState.uiOptions.vimMode
? [
// Workaround for https://github.com/replit/codemirror-vim/issues/182;
// without this, Enter does nothing for ordinary paragraphs in insert
// mode.
{
key: "Enter",
run: insertNewlineAndIndent,
shift: insertNewlineAndIndent,
},
]
: standardKeymap,
...completionKeymap,
indentWithTab,
]);
Expand Down

0 comments on commit 916c84e

Please sign in to comment.