Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletion src/guide.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<GuideAction>,
Expand All @@ -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),
}
};
Expand Down
5 changes: 4 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
]
Expand Down