diff options
author | Peter DeLong <petersdelong@gmail.com> | 2022-07-26 05:15:40 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-26 12:15:40 +0300 |
commit | f4304d5a308e5341eb0a944b77c80d4821a13dbb (patch) | |
tree | 0e89dfcb8a138b1a61ceb1cd16c9e858192978ce | |
parent | 766a3b5582fa8ee13506c0f23c9c145ff0012078 (diff) | |
download | alacritty-f4304d5a308e5341eb0a944b77c80d4821a13dbb.tar.gz alacritty-f4304d5a308e5341eb0a944b77c80d4821a13dbb.zip |
Fix visible regex match on tall viewports
The end of the search window is currently calculated using the viewport
start instead of the end. The observed behavior is that all hinting
stops suddenly after line 101. This was introduced in #6139 when the
code was refactored into this file from display/content.rs.
-rw-r--r-- | alacritty/src/display/hint.rs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/alacritty/src/display/hint.rs b/alacritty/src/display/hint.rs index ace39d4c..8d374bdb 100644 --- a/alacritty/src/display/hint.rs +++ b/alacritty/src/display/hint.rs @@ -290,7 +290,7 @@ pub fn visible_regex_match_iter<'a, T>( let mut start = term.line_search_left(Point::new(viewport_start, Column(0))); let mut end = term.line_search_right(Point::new(viewport_end, Column(0))); start.line = start.line.max(viewport_start - MAX_SEARCH_LINES); - end.line = end.line.min(viewport_start + MAX_SEARCH_LINES); + end.line = end.line.min(viewport_end + MAX_SEARCH_LINES); RegexIter::new(start, end, Direction::Right, term, regex) .skip_while(move |rm| rm.end().line < viewport_start) @@ -680,4 +680,16 @@ mod tests { ); assert_eq!(None, unique_hyperlinks.next()); } + + #[test] + fn visible_regex_match_covers_entire_viewport() { + let content = "I'm a match!\r\n".repeat(4096); + // The Term returned from this call will have a viewport starting at 0 and ending at 4096. + // That's good enough for this test, since it only cares about visible content. + let term = mock_term(&content); + let regex = RegexSearch::new("match!").unwrap(); + + // The interator should match everything in the viewport. + assert_eq!(visible_regex_match_iter(&term, ®ex).count(), 4096); + } } |