Skip to content

Commit 660f43c

Browse files
committed
fix(vim): only use jump motion if in visual mode
Fix regression in mark's behaviour, where a mark with multiple anchors was not activating all anchors again when jumping to that mark in normal mode, as `Motion::Jump` was being used even if not in visual mode. This commit fixes the issue by only using jump motion if in visual mode, making sure that the behaviour stays the same as before.
1 parent 1d7761c commit 660f43c

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

crates/vim/src/normal/mark.rs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,11 @@ impl Vim {
122122
} else {
123123
// Save the last anchor so as to jump to it later.
124124
let anchor: Option<Anchor> = anchors.last_mut().map(|last| last.clone());
125+
let should_jump = self.mode == Mode::Visual
126+
|| self.mode == Mode::VisualLine
127+
|| self.mode == Mode::VisualBlock;
125128

126-
self.update_editor(window, cx, |vim, editor, window, cx| {
129+
self.update_editor(window, cx, |_, editor, window, cx| {
127130
let map = editor.snapshot(window, cx);
128131
let mut ranges: Vec<Range<Anchor>> = Vec::new();
129132
for mut anchor in anchors {
@@ -141,18 +144,22 @@ impl Vim {
141144
}
142145
}
143146

144-
if vim.mode != Mode::Visual
145-
&& vim.mode != Mode::VisualLine
146-
&& vim.mode != Mode::VisualBlock
147-
{
147+
if !should_jump {
148148
editor.change_selections(Some(Autoscroll::fit()), window, cx, |s| {
149149
s.select_anchor_ranges(ranges)
150150
});
151151
}
152152
});
153153

154-
if let Some(anchor) = anchor {
155-
self.motion(Motion::Jump { anchor, line }, window, cx)
154+
if should_jump && anchor.is_some() {
155+
self.motion(
156+
Motion::Jump {
157+
anchor: anchor.unwrap(),
158+
line,
159+
},
160+
window,
161+
cx,
162+
)
156163
}
157164
}
158165
}

0 commit comments

Comments
 (0)