From bac80a6b5ae8af4c6e548df8a02029605ce3b13f Mon Sep 17 00:00:00 2001 From: lukeflo Date: Fri, 25 Oct 2024 13:55:02 +0200 Subject: [PATCH] fix(ui): Make visible cursor in search field move with index --- src/tui/ui.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/tui/ui.rs b/src/tui/ui.rs index 144bbf4..517a873 100644 --- a/src/tui/ui.rs +++ b/src/tui/ui.rs @@ -931,13 +931,10 @@ pub fn render_strings(state: &mut State, frame: &mut Frame, rect: Rect) { /// Renders the cursor. fn render_cursor(state: &mut State<'_>, area: Rect, frame: &mut Frame<'_>) { + let scroll = state.input.visual_scroll(area.width as usize); if state.input_mode { let (x, y) = ( - area.x - + Input::default() - .with_value(format!("search: {}", state.input.value())) - .visual_cursor() as u16 - + 2, + area.x + ((state.input.visual_cursor()).max(scroll) - scroll) as u16 + 10, // +10: simply to jump over the box chars and "search: " string area.bottom().saturating_sub(1), ); frame.render_widget(