From fce0ada0173ea5fd0b824035dec083be2177072b Mon Sep 17 00:00:00 2001 From: Basile Henry Date: Sat, 6 Apr 2024 20:19:14 +0200 Subject: [PATCH] helix-term: Provide some visual feedback for the substring match in history --- helix-term/src/ui/prompt.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/helix-term/src/ui/prompt.rs b/helix-term/src/ui/prompt.rs index 3eac78196..5b62d5ca4 100644 --- a/helix-term/src/ui/prompt.rs +++ b/helix-term/src/ui/prompt.rs @@ -537,6 +537,28 @@ impl Prompt { ) .into(); text.render(line_area, surface, cx); + } else if let Some((pre, substr, post)) = + self.history_substring.as_ref().and_then(|substr| { + self.line + .split_once(substr) + .map(|(pre, post)| (pre, substr, post)) + }) + { + surface.set_string(line_area.x, line_area.y, pre, prompt_color); + + surface.set_string( + line_area.x + pre.len() as u16, + line_area.y, + substr, + selected_color, + ); + + surface.set_string( + line_area.x + (pre.len() + substr.len()) as u16, + line_area.y, + post, + prompt_color, + ); } else { surface.set_string(line_area.x, line_area.y, self.line.clone(), prompt_color); }