@marimo-team/islands 0.23.16-dev26 → 0.23.16-dev28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,6 +4,7 @@ import { syntaxTree } from "@codemirror/language";
4
4
  import type { EditorState } from "@codemirror/state";
5
5
  import { EditorView } from "@codemirror/view";
6
6
  import type { SyntaxNode, Tree, TreeCursor } from "@lezer/common";
7
+ import { scrollOwnerCell } from "../utils";
7
8
 
8
9
  const SCOPE_CREATING_NODES = new Set([
9
10
  "FunctionDefinition",
@@ -45,6 +46,8 @@ function goToPosition(view: EditorView, from: number): void {
45
46
  }),
46
47
  });
47
48
  });
49
+
50
+ scrollOwnerCell(view);
48
51
  }
49
52
 
50
53
  function findFirstMatchingVariable(
@@ -52,6 +52,34 @@ export function focusInputAndMoveToEnd(
52
52
  });
53
53
  }
54
54
 
55
+ /**
56
+ * Scrolls the `.marimo-cell` that owns `view` into view.
57
+ *
58
+ * `EditorView.scrollIntoView` doesn't work in columns mode: it stops at the
59
+ * first overflowing ancestor even if that ancestor doesn't actually scroll,
60
+ * so it never reaches the real horizontally-scrolling container. The
61
+ * browser's native `Element.scrollIntoView` doesn't have that problem.
62
+ *
63
+ * Deferred a frame so CodeMirror's own scroll settles first; otherwise it
64
+ * clamps this scroll right back.
65
+ *
66
+ * https://github.com/marimo-team/marimo/issues/10222
67
+ */
68
+ export function scrollOwnerCell(view: EditorView): void {
69
+ const cell = view.dom.closest(".marimo-cell");
70
+ if (!cell) {
71
+ return;
72
+ }
73
+
74
+ requestAnimationFrame(() => {
75
+ cell.scrollIntoView({
76
+ behavior: "instant",
77
+ block: "nearest",
78
+ inline: "nearest",
79
+ });
80
+ });
81
+ }
82
+
55
83
  export function isInVimMode(ev: EditorView): boolean {
56
84
  return getCM(ev)?.state.vim != null;
57
85
  }