Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

fix: vim <CR> carriage return (#3370)

Myles Scolnickac16ef37de84
diff --git a/frontend/src/core/codemirror/__tests__/__snapshots__/setup.test.ts.snap b/frontend/src/core/codemirror/__tests__/__snapshots__/setup.test.ts.snap
index 032b0dfb74..bb5e302cde 100644
--- a/frontend/src/core/codemirror/__tests__/__snapshots__/setup.test.ts.snap
+++ b/frontend/src/core/codemirror/__tests__/__snapshots__/setup.test.ts.snap
@@ -166,17 +166,6 @@ exports[`snapshot all duplicate keymaps > vim keymaps 2`] = `
"shift": "deleteCharBackward",
},
],
- "Enter": [
- {
- "key": "Enter",
- "run": "acceptCompletion",
- },
- {
- "key": "Enter",
- "run": "<no name>",
- "shift": "<no name>",
- },
- ],
"Escape": [
{
"key": "Escape",
diff --git a/frontend/src/core/codemirror/__tests__/setup.test.ts b/frontend/src/core/codemirror/__tests__/setup.test.ts
index 84cfb7eaf7..b0d127ad61 100644
--- a/frontend/src/core/codemirror/__tests__/setup.test.ts
+++ b/frontend/src/core/codemirror/__tests__/setup.test.ts
@@ -115,7 +115,7 @@ describe("snapshot all duplicate keymaps", () => {
);
// Total duplicates:
// if this changes, please make sure to validate they are not conflicting
- expect(Object.values(duplicates).flat().length).toMatchInlineSnapshot("19");
+ expect(Object.values(duplicates).flat().length).toMatchInlineSnapshot("17");
expect(duplicates).toMatchSnapshot();
});
});
diff --git a/frontend/src/core/codemirror/keymaps/keymaps.ts b/frontend/src/core/codemirror/keymaps/keymaps.ts
index d92a16ea52..194dd93573 100644
--- a/frontend/src/core/codemirror/keymaps/keymaps.ts
+++ b/frontend/src/core/codemirror/keymaps/keymaps.ts
@@ -6,6 +6,7 @@ import { type Extension, Prec } from "@codemirror/state";
import { type EditorView, keymap } from "@codemirror/view";
import { vim } from "@replit/codemirror-vim";
import { vimKeymapExtension } from "./vim";
+import { once } from "@/utils/once";
export const KEYMAP_PRESETS = ["default", "vim"] as const;
@@ -48,10 +49,10 @@ export function keymapBundle(
},
),
),
+ keymap.of(defaultVimKeymap()),
vim({ status: false }),
// Needs to come after the vim extension
vimKeymapExtension(callbacks),
- keymap.of(defaultKeymap),
];
default:
logNever(config.preset);
@@ -59,6 +60,11 @@ export function keymapBundle(
}
}
+const defaultVimKeymap = once(() => {
+ // Remove Enter (<CR>) from the keymap
+ return defaultKeymap.filter((k) => k.key !== "Enter");
+});
+
/**
* Listen for a double keypress of a character and call a callback.
*/