feat: do not render hint on focused match

This commit is contained in:
graelo 2020-06-01 10:34:20 +02:00
parent 31e0d5cc9e
commit 92ced5d3bd

View file

@ -282,8 +282,10 @@ impl<'a> View<'a> {
&self.rendering_colors, &self.rendering_colors,
); );
// 3. Render the hint (e.g. "eo") as an overlay on top of the rendered matched text, if !focused {
// aligned at its leading or the trailing edge. // 3. If not focused, render the hint (e.g. "eo") as an overlay on
// top of the rendered matched text, aligned at its leading or the
// trailing edge.
let extra_offset = match self.hint_alignment { let extra_offset = match self.hint_alignment {
HintAlignment::Leading => 0, HintAlignment::Leading => 0,
HintAlignment::Trailing => text.len() - mat.hint.len(), HintAlignment::Trailing => text.len() - mat.hint.len(),
@ -297,6 +299,7 @@ impl<'a> View<'a> {
&self.hint_style, &self.hint_style,
); );
} }
}
stdout.flush().unwrap(); stdout.flush().unwrap();
} }
@ -891,25 +894,28 @@ Barcelona https://en.wikipedia.org/wiki/Barcelona - ";
) )
}; };
let expected_match2_hint = { // Because reverse is true, this second match is focused,
let goto11_3 = cursor::Goto(11, 3); // then the hint should not be rendered.
format!( // let expected_match2_hint = {
"{goto11_3}{hint_bg}{hint_fg}a{fg_reset}{bg_reset}", // let goto11_3 = cursor::Goto(11, 3);
goto11_3 = goto11_3,
hint_fg = color::Fg(rendering_colors.hint_fg.as_ref()), // format!(
hint_bg = color::Bg(rendering_colors.hint_bg.as_ref()), // "{goto11_3}{hint_bg}{hint_fg}a{fg_reset}{bg_reset}",
fg_reset = color::Fg(color::Reset), // goto11_3 = goto11_3,
bg_reset = color::Bg(color::Reset) // hint_fg = color::Fg(rendering_colors.hint_fg.as_ref()),
) // hint_bg = color::Bg(rendering_colors.hint_bg.as_ref()),
}; // fg_reset = color::Fg(color::Reset),
// bg_reset = color::Bg(color::Reset)
// )
// };
let expected = [ let expected = [
expected_content, expected_content,
expected_match1_text, expected_match1_text,
expected_match1_hint, expected_match1_hint,
expected_match2_text, expected_match2_text,
expected_match2_hint, // expected_match2_hint,
] ]
.concat(); .concat();