diff options
author | Christian Duerr <contact@christianduerr.com> | 2024-01-14 16:07:40 +0100 |
---|---|---|
committer | Christian Duerr <contact@christianduerr.com> | 2024-03-19 02:20:53 +0100 |
commit | 9458550c777c54f30ef70954cbcbf774989cc39c (patch) | |
tree | 58e2ac16bdb8d8902daddb10b6e1fc35f9b719a9 | |
parent | 915aa655711eaad0ba942cc7b84c1760e8cd19a0 (diff) | |
download | alacritty-9458550c777c54f30ef70954cbcbf774989cc39c.tar.gz alacritty-9458550c777c54f30ef70954cbcbf774989cc39c.zip |
Fix inline search expanding across newlines
Closes #7587.
-rw-r--r-- | CHANGELOG.md | 6 | ||||
-rw-r--r-- | alacritty_terminal/src/term/search.rs | 34 |
2 files changed, 36 insertions, 4 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a0e06c8..e34d9e0f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ The sections should follow the order `Packaging`, `Added`, `Changed`, `Fixed` an The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). +## 0.13.2-dev + +### Fixed + +- Vi inline search/semantic selection expanding across newlines + ## 0.13.1 ### Added diff --git a/alacritty_terminal/src/term/search.rs b/alacritty_terminal/src/term/search.rs index 9e900b8a..585e191c 100644 --- a/alacritty_terminal/src/term/search.rs +++ b/alacritty_terminal/src/term/search.rs @@ -540,15 +540,15 @@ impl<T> Term<T> { let wide = Flags::WIDE_CHAR | Flags::WIDE_CHAR_SPACER | Flags::LEADING_WIDE_CHAR_SPACER; while let Some(cell) = iter.prev() { + if cell.point.column == last_column && !cell.flags.contains(Flags::WRAPLINE) { + break; + } + point = cell.point; if !cell.flags.intersects(wide) && needles.contains(cell.c) { return Ok(point); } - - if point.column == last_column && !cell.flags.contains(Flags::WRAPLINE) { - break; - } } Err(point) @@ -562,6 +562,11 @@ impl<T> Term<T> { let wide = Flags::WIDE_CHAR | Flags::WIDE_CHAR_SPACER | Flags::LEADING_WIDE_CHAR_SPACER; let last_column = self.columns() - 1; + // Immediately stop if start point in on line break. + if point.column == last_column && !self.grid[point].flags.contains(Flags::WRAPLINE) { + return Err(point); + } + for cell in self.grid.iter_from(point) { point = cell.point; @@ -1129,4 +1134,25 @@ mod tests { let end = Point::new(Line(0), Column(3)); assert_eq!(term.regex_search_right(&mut regex, start, end), Some(start..=end)); } + + #[test] + fn newline_breaking_semantic() { + #[rustfmt::skip] + let term = mock_term("\ + test abc\r\n\ + def test\ + "); + + // Start at last character. + let start = term.semantic_search_left(Point::new(Line(0), Column(7))); + let end = term.semantic_search_right(Point::new(Line(0), Column(7))); + assert_eq!(start, Point::new(Line(0), Column(5))); + assert_eq!(end, Point::new(Line(0), Column(7))); + + // Start at first character. + let start = term.semantic_search_left(Point::new(Line(1), Column(0))); + let end = term.semantic_search_right(Point::new(Line(1), Column(0))); + assert_eq!(start, Point::new(Line(1), Column(0))); + assert_eq!(end, Point::new(Line(1), Column(2))); + } } |