mirror of
https://github.com/alacritty/alacritty.git
synced 2024-11-25 14:05:41 -05:00
Fix regex search regression
This commit is contained in:
parent
7e4325796d
commit
fa2fa39804
1 changed files with 33 additions and 8 deletions
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue