Skip to content

Commit c9febfc

Browse files
paneutrallidm0707
authored andcommitted
vim: Fix cursor movement after entering Helix normal mode (zed-industries#40528)
Closes zed-industries#40009 Release Notes: - `vim::NormalBefore` now enters `helix_normal` correctly.
1 parent 4af108e commit c9febfc

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

crates/vim/src/insert.rs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,23 @@ impl Vim {
5050
if count <= 1 || Vim::globals(cx).dot_replaying {
5151
self.create_mark("^".into(), window, cx);
5252

53+
if HelixModeSetting::get_global(cx).0 {
54+
self.update_editor(cx, |_, editor, cx| {
55+
editor.dismiss_menus_and_popups(false, window, cx);
56+
});
57+
self.switch_mode(Mode::HelixNormal, false, window, cx);
58+
return;
59+
}
60+
5361
self.update_editor(cx, |_, editor, cx| {
5462
editor.dismiss_menus_and_popups(false, window, cx);
5563

56-
if !HelixModeSetting::get_global(cx).0 {
57-
editor.change_selections(Default::default(), window, cx, |s| {
58-
s.move_cursors_with(|map, mut cursor, _| {
59-
*cursor.column_mut() = cursor.column().saturating_sub(1);
60-
(map.clip_point(cursor, Bias::Left), SelectionGoal::None)
61-
});
64+
editor.change_selections(Default::default(), window, cx, |s| {
65+
s.move_cursors_with(|map, mut cursor, _| {
66+
*cursor.column_mut() = cursor.column().saturating_sub(1);
67+
(map.clip_point(cursor, Bias::Left), SelectionGoal::None)
6268
});
63-
}
69+
});
6470
});
6571

6672
self.switch_mode(Mode::Normal, false, window, cx);

0 commit comments

Comments
 (0)