From 7f276d3a9c56a84ef53dc483a83e7e72d777c5c3 Mon Sep 17 00:00:00 2001 From: Lennart Kloock Date: Sun, 16 Nov 2025 14:54:00 +0100 Subject: [PATCH 1/2] vim: Fix cursor shape after deactivation --- crates/vim/src/vim.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/vim/src/vim.rs b/crates/vim/src/vim.rs index 6ffdbcce910c10..638c77f0e90971 100644 --- a/crates/vim/src/vim.rs +++ b/crates/vim/src/vim.rs @@ -952,7 +952,12 @@ impl Vim { } fn deactivate(editor: &mut Editor, cx: &mut Context) { - editor.set_cursor_shape(CursorShape::Bar, cx); + editor.set_cursor_shape( + EditorSettings::get_global(cx) + .cursor_shape + .unwrap_or_default(), + cx, + ); editor.set_clip_at_line_ends(false, cx); editor.set_input_enabled(true); editor.set_autoindent(true); From eec9eb0fb7ba891ed4650138576573d68f3485ed Mon Sep 17 00:00:00 2001 From: dino Date: Mon, 24 Nov 2025 16:12:48 -0500 Subject: [PATCH 2/2] test(vim): ensure cursor shape is updated to the one in settings --- crates/editor/src/editor.rs | 4 ++++ crates/vim/src/test.rs | 26 +++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 8cb3d1abf7d026..18f82ca6316ca0 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -3006,6 +3006,10 @@ impl Editor { cx.notify(); } + pub fn cursor_shape(&self) -> CursorShape { + self.cursor_shape + } + pub fn set_current_line_highlight( &mut self, current_line_highlight: Option, diff --git a/crates/vim/src/test.rs b/crates/vim/src/test.rs index d6aa116e8ddb12..a78cc25cdbd2b4 100644 --- a/crates/vim/src/test.rs +++ b/crates/vim/src/test.rs @@ -16,7 +16,7 @@ use editor::{ use futures::StreamExt; use gpui::{KeyBinding, Modifiers, MouseButton, TestAppContext, px}; use itertools::Itertools; -use language::{Language, LanguageConfig, Point}; +use language::{CursorShape, Language, LanguageConfig, Point}; pub use neovim_backed_test_context::*; use settings::SettingsStore; use ui::Pixels; @@ -2381,3 +2381,27 @@ async fn test_repeat_grouping_41735(cx: &mut gpui::TestAppContext) { cx.simulate_shared_keystrokes("u").await; cx.shared_state().await.assert_eq("ˇaaa"); } + +#[gpui::test] +async fn test_deactivate(cx: &mut gpui::TestAppContext) { + let mut cx = VimTestContext::new(cx, true).await; + + cx.update_global(|store: &mut SettingsStore, cx| { + store.update_user_settings(cx, |settings| { + settings.editor.cursor_shape = Some(settings::CursorShape::Underline); + }); + }); + + // Assert that, while in `Normal` mode, the cursor shape is `Block` but, + // after deactivating vim mode, it should revert to the one specified in the + // user's settings, if set. + cx.update_editor(|editor, _window, _cx| { + assert_eq!(editor.cursor_shape(), CursorShape::Block); + }); + + cx.disable_vim(); + + cx.update_editor(|editor, _window, _cx| { + assert_eq!(editor.cursor_shape(), CursorShape::Underline); + }); +}