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: dont auto-run markdown on mount, dont auto-scroll unfocused cells (#2254)
Myles Scolnickbcab3193d4c1
diff --git a/frontend/src/core/codemirror/cells/extensions.ts b/frontend/src/core/codemirror/cells/extensions.tsindex 1719c0aede..52c07e3e4f 100644--- a/frontend/src/core/codemirror/cells/extensions.ts+++ b/frontend/src/core/codemirror/cells/extensions.ts@@ -293,12 +293,12 @@ export function cellCodeEditingBundle(const { updateCellCode } = callbacks;const onChangePlugin = EditorView.updateListener.of((update) => {- // Check if the doc update was a formatting change- // e.g. changing from python to markdown- const isFormattingChange = update.transactions.some((tr) =>- tr.effects.some((effect) => effect.is(formattingChangeEffect)),- );if (update.docChanged) {+ // Check if the doc update was a formatting change+ // e.g. changing from python to markdown+ const isFormattingChange = update.transactions.some((tr) =>+ tr.effects.some((effect) => effect.is(formattingChangeEffect)),+ );const nextCode = getEditorCodeAsPython(update.view);updateCellCode({cellId,@@ -318,8 +318,20 @@ export function markdownAutoRunExtension(callbacks: MovementCallbacks,): Extension {return EditorView.updateListener.of((update) => {- if (update.docChanged) {- callbacks.onRun();+ // If the doc didn't change, ignore+ if (!update.docChanged) {+ return;+ }++ // This happens on mount when we start in markdown mode+ const isFormattingChange = update.transactions.some((tr) =>+ tr.effects.some((effect) => effect.is(formattingChangeEffect)),+ );+ if (isFormattingChange) {+ // Ignore formatting changes+ return;}++ callbacks.onRun();});}diff --git a/frontend/src/core/codemirror/copilot/extension.ts b/frontend/src/core/codemirror/copilot/extension.tsindex 3ad3067220..b3c0916f79 100644--- a/frontend/src/core/codemirror/copilot/extension.ts+++ b/frontend/src/core/codemirror/copilot/extension.ts@@ -75,7 +75,9 @@ export const copilotBundle = (config: CompletionConfig): Extension => {request.doc.position,state,);- Logger.debug("Copilot suggestion:", suggestion);+ if (suggestion) {+ Logger.debug("Copilot suggestion:", suggestion);+ }return suggestion;},}),diff --git a/frontend/src/core/codemirror/extensions.ts b/frontend/src/core/codemirror/extensions.tsindex 4daefa8487..c804a106dd 100644--- a/frontend/src/core/codemirror/extensions.ts+++ b/frontend/src/core/codemirror/extensions.ts@@ -1,7 +1,7 @@/* Copyright 2024 Marimo. All rights reserved. */import { EditorView, keymap } from "@codemirror/view";import type { CellId } from "../cells/ids";-import { formatEditorViews } from "./format";+import { formatEditorViews, formattingChangeEffect } from "./format";import {getCurrentLanguageAdapter,toggleToLanguage,@@ -60,8 +60,21 @@ export function formatKeymapExtension(*/export function scrollActiveLineIntoView() {return EditorView.updateListener.of((update) => {+ // Ignore the editor does not have focus, ignore+ if (!update.view.hasFocus) {+ return;+ }+// A new line was added, scroll the active line into viewif (update.heightChanged && update.docChanged) {+ // Ignore formatting changes+ const isFormattingChange = update.transactions.some((tr) =>+ tr.effects.some((effect) => effect.is(formattingChangeEffect)),+ );+ if (isFormattingChange) {+ return;+ }+const activeLines = update.view.dom.getElementsByClassName("cm-activeLine cm-line",);