mirror of
https://github.com/TECHNOFAB11/tmux-copyrat.git
synced 2025-12-12 16:10:07 +01:00
feat: do not render hint on focused match
This commit is contained in:
parent
31e0d5cc9e
commit
92ced5d3bd
1 changed files with 31 additions and 25 deletions
34
src/view.rs
34
src/view.rs
|
|
@ -282,8 +282,10 @@ impl<'a> View<'a> {
|
|||
&self.rendering_colors,
|
||||
);
|
||||
|
||||
// 3. Render the hint (e.g. "eo") as an overlay on top of the rendered matched text,
|
||||
// aligned at its leading or the trailing edge.
|
||||
if !focused {
|
||||
// 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 {
|
||||
HintAlignment::Leading => 0,
|
||||
HintAlignment::Trailing => text.len() - mat.hint.len(),
|
||||
|
|
@ -297,6 +299,7 @@ impl<'a> View<'a> {
|
|||
&self.hint_style,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
stdout.flush().unwrap();
|
||||
}
|
||||
|
|
@ -891,25 +894,28 @@ Barcelona https://en.wikipedia.org/wiki/Barcelona - ";
|
|||
)
|
||||
};
|
||||
|
||||
let expected_match2_hint = {
|
||||
let goto11_3 = cursor::Goto(11, 3);
|
||||
// Because reverse is true, this second match is focused,
|
||||
// then the hint should not be rendered.
|
||||
|
||||
format!(
|
||||
"{goto11_3}{hint_bg}{hint_fg}a{fg_reset}{bg_reset}",
|
||||
goto11_3 = goto11_3,
|
||||
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_match2_hint = {
|
||||
// let goto11_3 = cursor::Goto(11, 3);
|
||||
|
||||
// format!(
|
||||
// "{goto11_3}{hint_bg}{hint_fg}a{fg_reset}{bg_reset}",
|
||||
// goto11_3 = goto11_3,
|
||||
// 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 = [
|
||||
expected_content,
|
||||
expected_match1_text,
|
||||
expected_match1_hint,
|
||||
expected_match2_text,
|
||||
expected_match2_hint,
|
||||
// expected_match2_hint,
|
||||
]
|
||||
.concat();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue