From b6e8db244c3da587d1db2d2999383847e3d2dcc2 Mon Sep 17 00:00:00 2001 From: smit <0xtimsb@gmail.com> Date: Thu, 27 Feb 2025 00:40:46 +0530 Subject: [PATCH] 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 --- crates/vim/src/normal/search.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/crates/vim/src/normal/search.rs b/crates/vim/src/normal/search.rs index 81d2897e59..23b5ab3f69 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;