summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Duerr <contact@christianduerr.com>2021-02-18 20:27:52 +0000
committerGitHub <noreply@github.com>2021-02-18 20:27:52 +0000
commit3dafec076b7a69aaa80a66f9de9930da78d23c00 (patch)
tree12b048a192047af4556c2165040f273a851f790a
parent6f1ddf70102acd2088cebf4c730b174d6b4570b6 (diff)
downloadalacritty-3dafec076b7a69aaa80a66f9de9930da78d23c00.tar.gz
alacritty-3dafec076b7a69aaa80a66f9de9930da78d23c00.zip
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 #4800.
-rw-r--r--alacritty_terminal/src/term/search.rs15
1 files changed, 12 insertions, 3 deletions
diff --git a/alacritty_terminal/src/term/search.rs b/alacritty_terminal/src/term/search.rs
index ee0cfdcb..d4fd61eb 100644
--- a/alacritty_terminal/src/term/search.rs
+++ b/alacritty_terminal/src/term/search.rs
@@ -469,16 +469,25 @@ impl<'a, T> Iterator for RegexIter<'a, T> {
type Item = Match;
fn next(&mut self) -> Option<Self::Item> {
+ if self.done {
+ return None;
+ }
+
+ // Since the end itself might be a single cell match, we search one more time.
if self.point == self.end {
self.done = true;
- } else if self.done {
- return None;
}
let regex_match = self.next_match()?;
self.point = *regex_match.end();
- self.skip();
+ if self.point == self.end {
+ // Stop when the match terminates right on the end limit.
+ self.done = true;
+ } else {
+ // Move the new search origin past the match.
+ self.skip();
+ }
Some(regex_match)
}