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 search submit panic (#25673)

smitb6e8db244c3d
diff --git a/crates/vim/src/normal/search.rs b/crates/vim/src/normal/search.rs
index 81d2897e59c..23b5ab3f699 100644
--- a/crates/vim/src/normal/search.rs
+++ b/crates/vim/src/normal/search.rs
@@ -187,9 +187,13 @@ impl Vim {
let direction = self.search.direction;
search_bar.has_active_match();
let new_head = new_selections.last().unwrap().start;
- let old_head = self.search.prior_selections.last().unwrap().start;
+ let is_different_head = self
+ .search
+ .prior_selections
+ .last()
+ .map_or(true, |range| range.start != new_head);
- if new_head != old_head && self.search.direction == Direction::Next {
+ if is_different_head && self.search.direction == Direction::Next {
count = count.saturating_sub(1)
}
self.search.count = 1;