Skip to content

Commit 065e41d

Browse files
committed
Hide vim cursor(s) when in command mode
517e6d3 addressed multiple visible cursors with Vim bindings using the last focused editor, but modal editing introduced new states we didn't account for. These changes ensure the vim block is hidden entirely while in command mode.
1 parent 85cfa0c commit 065e41d

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

frontend/src/core/codemirror/vim/cursor-visibility.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* Copyright 2024 Marimo. All rights reserved. */
22

33
import type { EditorView, PluginValue } from "@codemirror/view";
4+
import { isAnyCellFocused } from "@/components/editor/navigation/focus-utils";
45

56
let lastFocusedEditorRef: WeakRef<EditorView> | null = null;
67

@@ -40,8 +41,14 @@ export class VimCursorVisibilityPlugin implements PluginValue {
4041
update() {
4142
const vimCursorLayer = this.view.dom.querySelector(".cm-vimCursorLayer");
4243
if (vimCursorLayer instanceof HTMLElement) {
43-
const isLastFocused = lastFocusedEditorRef?.deref() === this.view;
44-
vimCursorLayer.style.display = isLastFocused ? "" : "none";
44+
// Hide all vim cursors when in command mode
45+
if (isAnyCellFocused()) {
46+
vimCursorLayer.style.display = "none";
47+
} else {
48+
// Show cursor only in the last focused editor when in edit mode
49+
const isLastFocused = lastFocusedEditorRef?.deref() === this.view;
50+
vimCursorLayer.style.display = isLastFocused ? "" : "none";
51+
}
4552
}
4653
}
4754

0 commit comments

Comments
 (0)