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: fix toggling between markdown and python languages in code editor (#1761)
Myles Scolnick5fa84c0f633c
diff --git a/frontend/src/core/codemirror/extensions.ts b/frontend/src/core/codemirror/extensions.tsindex 260785090a..7cb1fe7139 100644--- a/frontend/src/core/codemirror/extensions.ts+++ b/frontend/src/core/codemirror/extensions.ts@@ -2,7 +2,10 @@import { EditorView, keymap } from "@codemirror/view";import type { CellId } from "../cells/ids";import { formatEditorViews } from "./format";-import { toggleToLanguage } from "./language/commands";+import {+ getCurrentLanguageAdapter,+ toggleToLanguage,+} from "./language/commands";import { smartScrollIntoView } from "../../utils/scroll";import { HotkeyProvider } from "@/core/hotkeys/hotkeys";import { invariant } from "@/utils/invariant";@@ -30,7 +33,13 @@ export function formatKeymapExtension(key: hotkeys.getHotkey("cell.viewAsMarkdown").key,preventDefault: true,run: (ev) => {- const response = toggleToLanguage(ev, "markdown");+ const currentLanguage = getCurrentLanguageAdapter(ev);+ if (currentLanguage !== "markdown" && currentLanguage !== "python") {+ return false;+ }+ const destinationLanguage =+ currentLanguage === "python" ? "markdown" : "python";+ const response = toggleToLanguage(ev, destinationLanguage);if (response === "markdown") {afterToggleMarkdown();}