Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

vim: Fix empty selections panic in `insert_at_previous` (#42504)

Lukas Wirth78f466559acc
diff --git a/crates/vim/src/normal.rs b/crates/vim/src/normal.rs
index 8b4aefcaac3..e200c24b944 100644
--- a/crates/vim/src/normal.rs
+++ b/crates/vim/src/normal.rs
@@ -671,13 +671,13 @@ impl Vim {
self.start_recording(cx);
self.switch_mode(Mode::Insert, false, window, cx);
self.update_editor(cx, |vim, editor, cx| {
- let Some(Mark::Local(marks)) = vim.get_mark("^", editor, window, cx) else {
- return;
- };
-
- editor.change_selections(Default::default(), window, cx, |s| {
- s.select_anchor_ranges(marks.iter().map(|mark| *mark..*mark))
- });
+ if let Some(Mark::Local(marks)) = vim.get_mark("^", editor, window, cx)
+ && !marks.is_empty()
+ {
+ editor.change_selections(Default::default(), window, cx, |s| {
+ s.select_anchor_ranges(marks.iter().map(|mark| *mark..*mark))
+ });
+ }
});
}