diff options
Diffstat (limited to 'alacritty_terminal')
-rw-r--r-- | alacritty_terminal/src/term/search.rs | 41 |
1 files changed, 33 insertions, 8 deletions
diff --git a/alacritty_terminal/src/term/search.rs b/alacritty_terminal/src/term/search.rs index fd90f0e1..bf7f43d1 100644 --- a/alacritty_terminal/src/term/search.rs +++ b/alacritty_terminal/src/term/search.rs @@ -239,12 +239,7 @@ impl<T> Term<T> { } // Stop once we've reached the target point. - // - // We check beyond the point itself to account for skipped characters after wide chars - // without spacer. - if (direction == Direction::Right && point >= end) - || (direction == Direction::Left && point <= end) - { + if point == end { break; } @@ -289,9 +284,14 @@ impl<T> Term<T> { direction: Direction, ) { match direction { - Direction::Right if cell.flags.contains(Flags::WIDE_CHAR) => { + // In the alternate screen buffer there might not be a wide char spacer after a wide + // char, so we only advance the iterator when the wide char is not in the last column. + Direction::Right + if cell.flags.contains(Flags::WIDE_CHAR) + && iter.point().column < self.last_column() => + { iter.next(); - }, + } Direction::Right if cell.flags.contains(Flags::LEADING_WIDE_CHAR_SPACER) => { if let Some(Indexed { cell: new_cell, .. }) = iter.next() { *cell = new_cell; @@ -798,4 +798,29 @@ mod tests { let mut iter = RegexIter::new(start, end, Direction::Right, &term, &dfas); assert_eq!(iter.next(), None); } + + #[test] + fn wrap_around_to_another_end() { + #[rustfmt::skip] + let term = mock_term("\ + abc\r\n\ + def\ + "); + + // Bottom to top. + let dfas = RegexSearch::new("abc").unwrap(); + let start = Point::new(Line(1), Column(0)); + let end = Point::new(Line(0), Column(2)); + let match_start = Point::new(Line(0), Column(0)); + let match_end = Point::new(Line(0), Column(2)); + assert_eq!(term.regex_search_right(&dfas, start, end), Some(match_start..=match_end)); + + // Top to bottom. + let dfas = RegexSearch::new("def").unwrap(); + let start = Point::new(Line(0), Column(2)); + let end = Point::new(Line(1), Column(0)); + let match_start = Point::new(Line(1), Column(0)); + let match_end = Point::new(Line(1), Column(2)); + assert_eq!(term.regex_search_left(&dfas, start, end), Some(match_start..=match_end)); + } } |