diff options
author | Christian Duerr <contact@christianduerr.com> | 2024-07-05 12:12:15 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-05 13:12:15 +0300 |
commit | b3f0f68184b0d6b6221a5955acfcc4e33c01b766 (patch) | |
tree | 3ea002e3f37f68f4b217657b1871ae3bd2fce79b /alacritty_terminal/src/term/search.rs | |
parent | 5e6b92db85b3ea7ffd06a7a5ae0d2d62ad5946a6 (diff) | |
download | alacritty-b3f0f68184b0d6b6221a5955acfcc4e33c01b766.tar.gz alacritty-b3f0f68184b0d6b6221a5955acfcc4e33c01b766.zip |
Fix search bug with wrapline on first character
This fixes an issue where an inline search in the left direction would
incorrectly assume that the first cell searched would not contain the
`WRAPLINE` flag, causing the second search for the match end to
terminate prematurely.
Fixes #8060.
Diffstat (limited to 'alacritty_terminal/src/term/search.rs')
-rw-r--r-- | alacritty_terminal/src/term/search.rs | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/alacritty_terminal/src/term/search.rs b/alacritty_terminal/src/term/search.rs index 585e191c..a5ae9337 100644 --- a/alacritty_terminal/src/term/search.rs +++ b/alacritty_terminal/src/term/search.rs @@ -293,12 +293,12 @@ impl<T> Term<T> { let mut state = regex.dfa.start_state_forward(&mut regex.cache, &input).unwrap(); let mut iter = self.grid.iter_from(start); - let mut last_wrapped = false; let mut regex_match = None; let mut done = false; let mut cell = iter.cell(); self.skip_fullwidth(&mut iter, &mut cell, regex.direction); + let mut last_wrapped = cell.flags.contains(Flags::WRAPLINE); let mut c = cell.c; let mut point = iter.point(); @@ -1155,4 +1155,20 @@ mod tests { assert_eq!(start, Point::new(Line(1), Column(0))); assert_eq!(end, Point::new(Line(1), Column(2))); } + + #[test] + fn inline_word_search() { + #[rustfmt::skip] + let term = mock_term("\ + word word word word w\n\ + ord word word word\ + "); + + let mut regex = RegexSearch::new("word").unwrap(); + let start = Point::new(Line(1), Column(4)); + let end = Point::new(Line(0), Column(0)); + let match_start = Point::new(Line(0), Column(20)); + let match_end = Point::new(Line(1), Column(2)); + assert_eq!(term.regex_search_left(&mut regex, start, end), Some(match_start..=match_end)); + } } |