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 committed by GitHub
parent 927b864844
commit b82a49ce0c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 4 deletions

View file

@ -7,6 +7,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## 0.14.0-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)));
}
}