vim: Fix search submit panic (#25673)

In file search submit action, handle unwrap when there are no prior
selection.

Fix is for recently made commits, hence no release notes.

Release Notes:

- N/A

---------

Co-authored-by: Anthony Eid <anthony@zed.dev>
This commit is contained in:
smit 2025-02-27 00:40:46 +05:30 committed by GitHub
parent 6267ab0396
commit b6e8db244c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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;