1
0
Fork 0
mirror of https://github.com/alacritty/alacritty.git synced 2024-11-18 13:55:23 -05:00

Fix inline search expanding across newlines

Closes #7587.
This commit is contained in:
Christian Duerr 2024-01-14 16:07:40 +01:00
parent 915aa65571
commit 9458550c77
2 changed files with 36 additions and 4 deletions

View file

@ -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

View file

@ -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)));
}
}