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: convert to markdown & sql (#5109)

Shahmir Varqha36cf1a5b2bf1
diff --git a/frontend/src/components/editor/actions/useCellActionButton.tsx b/frontend/src/components/editor/actions/useCellActionButton.tsx
index 446d52ef9a..e148d42dc8 100644
--- a/frontend/src/components/editor/actions/useCellActionButton.tsx
+++ b/frontend/src/components/editor/actions/useCellActionButton.tsx
@@ -273,7 +273,7 @@ export function useCellActionButtons({ cell }: Props) {
return;
}
maybeAddMarimoImport(autoInstantiate, createCell);
- switchLanguage(editorView, "markdown", { keepCodeAsIs: true });
+ switchLanguage(editorView, "markdown", { keepCodeAsIs: false });
},
},
{
@@ -285,7 +285,7 @@ export function useCellActionButtons({ cell }: Props) {
return;
}
maybeAddMarimoImport(autoInstantiate, createCell);
- switchLanguage(editorView, "sql", { keepCodeAsIs: true });
+ switchLanguage(editorView, "sql", { keepCodeAsIs: false });
},
},
{
diff --git a/frontend/src/core/codemirror/language/extension.ts b/frontend/src/core/codemirror/language/extension.ts
index c07bc79055..e17a40eafa 100644
--- a/frontend/src/core/codemirror/language/extension.ts
+++ b/frontend/src/core/codemirror/language/extension.ts
@@ -244,6 +244,12 @@ export function languageAdapterFromCode(doc: string): LanguageAdapter {
/**
* Switch the language of the editor.
+ *
+ * @param view - The editor view.
+ * @param language - The language to switch to.
+ * @param opts.keepCodeAsIs - If true, we keep the original code but update the language.
+ * If false, we transform the code from the current language to the next language and update
+ * the cursor position.
*/
export function switchLanguage(
view: EditorView,