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.

tab to accept resource context (#6921)

Shahmir Varqha15addbadffba
diff --git a/frontend/src/core/codemirror/ai/resources.ts b/frontend/src/core/codemirror/ai/resources.ts
index 4f944e44cd..48a8878f7a 100644
--- a/frontend/src/core/codemirror/ai/resources.ts
+++ b/frontend/src/core/codemirror/ai/resources.ts
@@ -1,8 +1,9 @@
/* Copyright 2024 Marimo. All rights reserved. */
+import { acceptCompletion } from "@codemirror/autocomplete";
import type { Language } from "@codemirror/language";
-import type { Extension } from "@codemirror/state";
-import type { TooltipView } from "@codemirror/view";
+import { type Extension, Prec } from "@codemirror/state";
+import { type EditorView, keymap, type TooltipView } from "@codemirror/view";
import {
hoverResource,
type Resource,
@@ -67,6 +68,16 @@ export function resourceExtension(opts: {
},
),
}),
+ Prec.high(
+ keymap.of([
+ {
+ key: "Tab",
+ run: (view: EditorView) => {
+ return acceptCompletion(view);
+ },
+ },
+ ]),
+ ),
contextCallbacks.of({
addAttachment: (attachment) => onAddFiles?.([attachment]),
}),