diff --git a/src/guide.rs b/src/guide.rs index f3f51eb..0abb5d6 100644 --- a/src/guide.rs +++ b/src/guide.rs @@ -80,6 +80,31 @@ pub fn copy_to_clipboard_message(content: &str) -> GuideMessage { } } +/// A guide state that occupies exactly one (blank) row. +/// +/// Used to reserve the guide line when there is no message to show, so the +/// pane never collapses to zero rows and the panes below it stay put. +fn blank_line() -> status::State { + status::State::new(" ", Severity::Success) +} + +/// Graphemes for the guide pane's initial state. +/// +/// With hints enabled this reserves one blank row so the guide line is present +/// from the first frame — otherwise the first message would shift the panes +/// below it. With `--no-hint` the guide is permanently empty. +pub fn initial_graphemes( + no_hint: bool, + width: u16, + height: u16, +) -> promkit_widgets::core::grapheme::StyledGraphemes { + if no_hint { + Default::default() + } else { + blank_line().create_graphemes(width, height) + } +} + /// Spawn a task that listens for guide actions and updates the guide view accordingly. pub fn start_guide_task( mut action_rx: mpsc::Receiver, @@ -96,7 +121,13 @@ pub fn start_guide_task( Default::default() } else { match action { - GuideAction::Clear => status::State::default().create_graphemes(area.0, area.1), + // Render a single blank line rather than an empty + // state. An empty state produces zero rows, which the + // renderer drops entirely (terminal.rs filters out + // empty panes), collapsing the guide line and shifting + // the JSON viewer up — and back down when a message + // reappears. Reserving one row keeps the layout stable. + GuideAction::Clear => blank_line().create_graphemes(area.0, area.1), GuideAction::Show(message) => message_to_state(message).create_graphemes(area.0, area.1), } }; diff --git a/src/main.rs b/src/main.rs index 15807d7..dc688f8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -242,7 +242,10 @@ async fn main() -> anyhow::Result<()> { Index::QueryEditor, query_editor.create_graphemes(terminal_size.0, terminal_size.1), ), - (Index::Guide, StyledGraphemes::default()), + ( + Index::Guide, + guide::initial_graphemes(config.no_hint, terminal_size.0, terminal_size.1), + ), (Index::Completion, StyledGraphemes::default()), (Index::JsonViewer, StyledGraphemes::default()), ]