Skip to content

Commit 3dafec0

Browse files
authored
Fix search freezing Alacritty
This resolves a regression introduced in 530de00 where searching would cause a deadlock when the viewport is at the bottom of the scrollback and a match ends in the last cell. Fixes alacritty#4800.
1 parent 6f1ddf7 commit 3dafec0

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

Diff for: alacritty_terminal/src/term/search.rs

+12-3
Original file line numberDiff line numberDiff line change
@@ -469,16 +469,25 @@ impl<'a, T> Iterator for RegexIter<'a, T> {
469469
type Item = Match;
470470

471471
fn next(&mut self) -> Option<Self::Item> {
472+
if self.done {
473+
return None;
474+
}
475+
476+
// Since the end itself might be a single cell match, we search one more time.
472477
if self.point == self.end {
473478
self.done = true;
474-
} else if self.done {
475-
return None;
476479
}
477480

478481
let regex_match = self.next_match()?;
479482

480483
self.point = *regex_match.end();
481-
self.skip();
484+
if self.point == self.end {
485+
// Stop when the match terminates right on the end limit.
486+
self.done = true;
487+
} else {
488+
// Move the new search origin past the match.
489+
self.skip();
490+
}
482491

483492
Some(regex_match)
484493
}

0 commit comments

Comments
 (0)