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.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
fix: vim keymap precedence (fix enter in insert mode) (#3395)
Myles Scolnick9c07b3ec0b33
diff --git a/frontend/src/core/codemirror/__tests__/__snapshots__/setup.test.ts.snap b/frontend/src/core/codemirror/__tests__/__snapshots__/setup.test.ts.snapindex bb5e302cde..032b0dfb74 100644--- a/frontend/src/core/codemirror/__tests__/__snapshots__/setup.test.ts.snap+++ b/frontend/src/core/codemirror/__tests__/__snapshots__/setup.test.ts.snap@@ -166,6 +166,17 @@ 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.tsindex b0d127ad61..84cfb7eaf7 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("17");+ expect(Object.values(duplicates).flat().length).toMatchInlineSnapshot("19");expect(duplicates).toMatchSnapshot();});});diff --git a/frontend/src/core/codemirror/keymaps/keymaps.ts b/frontend/src/core/codemirror/keymaps/keymaps.tsindex b1d1ed104b..e8af6ba66e 100644--- a/frontend/src/core/codemirror/keymaps/keymaps.ts+++ b/frontend/src/core/codemirror/keymaps/keymaps.ts@@ -6,7 +6,6 @@ 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;@@ -35,8 +34,9 @@ export function keymapBundle(];case "vim":return [+ keymap.of(defaultKeymap),// delete the cell on double press of "d", if the cell is empty- Prec.highest(+ Prec.high(doubleCharacterListener("d",(view) => view.state.doc.toString() === "",@@ -49,10 +49,9 @@ export function keymapBundle(},),),- keymap.of(defaultVimKeymap()),- vim({ status: false }),+ Prec.highest(vim({ status: false })),// Needs to come after the vim extension- vimKeymapExtension(callbacks),+ Prec.highest(vimKeymapExtension(callbacks)),];default:logNever(config.preset);@@ -60,20 +59,6 @@ export function keymapBundle(}}-const defaultVimKeymap = once(() => {- const toRemove = new Set(["Enter", "Ctrl-v", "ArrowLeft", "ArrowRight"]);- // Remove conflicting keys from the keymap- // Enter (<CR>) adds a new line- // - it should just go to the next line- // Ctrl-v goes to the bottom of the cell- // - should enter blockwise visual mode- // ArrowLeft/ArrowRight exit blockwise visual mode- // - should keep blockwise, but continue with cursor movement- return defaultKeymap.filter(- (k) => !toRemove.has(k.key || k.mac || k.linux || k.win || ""),- );-});-/*** Listen for a double keypress of a character and call a callback.*/