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.

Hide vim cursor(s) when in command mode (#5695)

Trevor Manzdefc7c65cc8d
diff --git a/frontend/src/core/codemirror/vim/cursor-visibility.ts b/frontend/src/core/codemirror/vim/cursor-visibility.ts
index d70bfd1b74..5b15b852a8 100644
--- a/frontend/src/core/codemirror/vim/cursor-visibility.ts
+++ b/frontend/src/core/codemirror/vim/cursor-visibility.ts
@@ -1,6 +1,7 @@
/* Copyright 2024 Marimo. All rights reserved. */
import type { EditorView, PluginValue } from "@codemirror/view";
+import { isAnyCellFocused } from "@/components/editor/navigation/focus-utils";
let lastFocusedEditorRef: WeakRef<EditorView> | null = null;
@@ -40,8 +41,14 @@ export class VimCursorVisibilityPlugin implements PluginValue {
update() {
const vimCursorLayer = this.view.dom.querySelector(".cm-vimCursorLayer");
if (vimCursorLayer instanceof HTMLElement) {
- const isLastFocused = lastFocusedEditorRef?.deref() === this.view;
- vimCursorLayer.style.display = isLastFocused ? "" : "none";
+ // Hide all vim cursors when in command mode
+ if (isAnyCellFocused()) {
+ vimCursorLayer.style.display = "none";
+ } else {
+ // Show cursor only in the last focused editor when in edit mode
+ const isLastFocused = lastFocusedEditorRef?.deref() === this.view;
+ vimCursorLayer.style.display = isLastFocused ? "" : "none";
+ }
}
}