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.

Add keymap to clear tooltips on Backspace press (#321)

Myles Scolnick0e86ca72aa6e
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 cfc4a6b465..3ad02b7df7 100644
--- a/frontend/src/core/codemirror/__tests__/__snapshots__/setup.test.ts.snap
+++ b/frontend/src/core/codemirror/__tests__/__snapshots__/setup.test.ts.snap
@@ -27,6 +27,10 @@ exports[`snapshot all duplicate keymaps > default keymaps 2`] = `
},
],
"Backspace": [
+ {
+ "key": "Backspace",
+ "run": "run",
+ },
{
"key": "Backspace",
"run": "deleteBracketPair",
@@ -135,6 +139,10 @@ exports[`snapshot all duplicate keymaps > vim keymaps 2`] = `
},
],
"Backspace": [
+ {
+ "key": "Backspace",
+ "run": "run",
+ },
{
"key": "Backspace",
"run": "deleteBracketPair",
diff --git a/frontend/src/core/codemirror/__tests__/setup.test.ts b/frontend/src/core/codemirror/__tests__/setup.test.ts
index 75a1e7201d..0881d043dc 100644
--- a/frontend/src/core/codemirror/__tests__/setup.test.ts
+++ b/frontend/src/core/codemirror/__tests__/setup.test.ts
@@ -88,7 +88,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("20");
expect(duplicates).toMatchSnapshot();
});
@@ -101,7 +101,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("18");
+ expect(Object.values(duplicates).flat().length).toMatchInlineSnapshot("19");
expect(duplicates).toMatchSnapshot();
});
});
diff --git a/frontend/src/core/codemirror/completion/hints.ts b/frontend/src/core/codemirror/completion/hints.ts
index 194b001d4f..c2610ac830 100644
--- a/frontend/src/core/codemirror/completion/hints.ts
+++ b/frontend/src/core/codemirror/completion/hints.ts
@@ -56,6 +56,17 @@ export function hintTooltip() {
},
])
),
+ Prec.highest(
+ keymap.of([
+ {
+ key: "Backspace",
+ run: (view) => {
+ clearTooltips(view);
+ return false; // don't stop propagation
+ },
+ },
+ ])
+ ),
// Clear tooltips on blur
EditorView.domEventObservers({
blur: (event, view) => {