fix: align pane bottoms and wrap navigation help

This commit is contained in:
Valdemar Lorenzen
2026-10-19 13:52:26 +02:00
parent 0ffcef494f
commit b15460d5f8
5 changed files with 20 additions and 13 deletions
+10 -5
View File
@@ -159,10 +159,10 @@ impl App {
);
return;
}
let [header, body, error_area] = Layout::vertical([
let [header, error_area, body] = Layout::vertical([
Constraint::Length(1),
Constraint::Length(u16::from(self.error.is_some())),
Constraint::Min(4),
Constraint::Length(1),
])
.areas(area);
frame.render_widget(
@@ -262,7 +262,7 @@ impl App {
} else if self.page.rows.is_empty() {
frame.render_widget(
Paragraph::new(if self.error.is_some() {
"Could not load rows. See error below."
"Could not load rows. See error above."
} else {
"No rows."
})
@@ -361,11 +361,12 @@ mod tests {
)?;
let mut app = super::App::new(crate::db::Database::open_sqlite(file.path())?)?;
let mut terminal = ratatui::Terminal::new(ratatui::backend::TestBackend::new(100, 20))?;
for schema in [false, true] {
for (schema, error) in [(false, None), (true, None), (false, Some("Read failed"))] {
app.show_schema = schema;
app.error = error.map(str::to_owned);
terminal.draw(|frame| app.draw(frame, frame.area(), true))?;
let buffer = terminal.backend().buffer();
let border: String = (0..100).map(|x| buffer[(x, 18)].symbol()).collect();
let border: String = (0..100).map(|x| buffer[(x, 19)].symbol()).collect();
assert!(border.starts_with("└ main.comments [table]"), "{border}");
assert!(border.ends_with('┘'), "{border}");
assert!(border.contains(if schema {
@@ -373,6 +374,10 @@ mod tests {
} else {
"rows 1–1"
}));
if let Some(error) = error {
let message: String = (0..100).map(|x| buffer[(x, 1)].symbol()).collect();
assert!(message.starts_with(error), "{message}");
}
}
Ok(())
}