fix: highlight all search matches before word navigation
This commit is contained in:
+68
-1
@@ -3122,7 +3122,7 @@ fn paint_editor_line(
|
||||
paint_grapheme_range(frame, area, left, line, start..end, style);
|
||||
}
|
||||
}
|
||||
if let Some(found) = editor.search_match().filter(|found| found.start.row == row) {
|
||||
for found in editor.search_matches_on_row(row) {
|
||||
paint_cells(
|
||||
frame,
|
||||
area,
|
||||
@@ -18877,6 +18877,73 @@ end
|
||||
assert_ne!(buffer[(6, 0)].bg, Color::Blue);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn search_highlights_all_occurrences_without_moving_on_first_star() {
|
||||
let mut editor = Editor::open(None, vec![]).unwrap();
|
||||
editor.set_gutter_style(crate::gutter::GutterStyle::None);
|
||||
configure_chrome(&mut editor, |top, bottom| {
|
||||
for bar in [top, bottom] {
|
||||
bar.left.clear();
|
||||
bar.center.clear();
|
||||
bar.right.clear();
|
||||
}
|
||||
});
|
||||
editor
|
||||
.apply(vec![crate::editor::Effect::Replace(
|
||||
"cat cat_cat cat\ncat".into(),
|
||||
)])
|
||||
.unwrap();
|
||||
editor.handle(Input::Char('*'));
|
||||
assert_eq!(editor.cursor(), Cursor::default());
|
||||
let mut terminal = Terminal::new(ratatui::backend::TestBackend::new(30, 6)).unwrap();
|
||||
let (mut top, mut left) = (0, 0);
|
||||
let mut syntax = SyntaxCache::new();
|
||||
terminal
|
||||
.draw(|frame| {
|
||||
draw(
|
||||
frame,
|
||||
&editor,
|
||||
&mut top,
|
||||
&mut left,
|
||||
&mut syntax,
|
||||
&mut DocumentViewport::default(),
|
||||
&mut WheelPanels::default(),
|
||||
);
|
||||
})
|
||||
.unwrap();
|
||||
let buffer = terminal.backend().buffer();
|
||||
for (row, start, end) in [(0, 0, 3), (0, 12, 15), (1, 0, 3)] {
|
||||
for column in start..end {
|
||||
assert_eq!(buffer[(column + 2, row)].bg, Color::Yellow);
|
||||
}
|
||||
}
|
||||
assert_ne!(buffer[(6, 0)].bg, Color::Yellow);
|
||||
editor.handle(Input::Char('/'));
|
||||
for ch in "cat".chars() {
|
||||
editor.handle(Input::Char(ch));
|
||||
}
|
||||
editor.handle(Input::Enter);
|
||||
terminal
|
||||
.draw(|frame| {
|
||||
draw(
|
||||
frame,
|
||||
&editor,
|
||||
&mut top,
|
||||
&mut left,
|
||||
&mut syntax,
|
||||
&mut DocumentViewport::default(),
|
||||
&mut WheelPanels::default(),
|
||||
);
|
||||
})
|
||||
.unwrap();
|
||||
for column in [0, 4, 8, 12] {
|
||||
assert_eq!(
|
||||
terminal.backend().buffer()[(column + 2, 0)].bg,
|
||||
Color::Yellow
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn active_search_highlight_uses_display_cells_and_clips_with_horizontal_scroll() {
|
||||
let mut editor = Editor::open(None, vec![]).unwrap();
|
||||
|
||||
Reference in New Issue
Block a user