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:
parent
6267ab0396
commit
b6e8db244c
1 changed files with 6 additions and 2 deletions
|
@ -187,9 +187,13 @@ impl Vim {
|
||||||
let direction = self.search.direction;
|
let direction = self.search.direction;
|
||||||
search_bar.has_active_match();
|
search_bar.has_active_match();
|
||||||
let new_head = new_selections.last().unwrap().start;
|
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)
|
count = count.saturating_sub(1)
|
||||||
}
|
}
|
||||||
self.search.count = 1;
|
self.search.count = 1;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue