feat: show N/A when cursor position is unavailable

This commit is contained in:
Valdemar Lorenzen
2026-10-19 16:08:32 +02:00
parent 522d9af0a7
commit 2ea3d53c2e
3 changed files with 38 additions and 18 deletions
+33 -15
View File
@@ -436,11 +436,9 @@ fn draw_bars(
);
frame.render_widget(Paragraph::new("").style(base), bottom);
let position = position.map(|(line, column)| format!(" {line}:{column} "));
let mode_width = bottom.width.min(10);
let position_width = position
.as_ref()
.map_or(0, |text| text.len() as u16 + 2)
.min(bottom.width.saturating_sub(mode_width));
let position = position.as_deref().unwrap_or(" N/A ");
let position_width = (position.len() as u16 + 2).min(bottom.width);
let mode_width = bottom.width.saturating_sub(position_width).min(10);
let [mode, name_area, cursor] = Layout::horizontal([
Constraint::Length(mode_width),
Constraint::Min(0),
@@ -456,16 +454,14 @@ fn draw_bars(
mode,
);
frame.render_widget(Paragraph::new(format!(" {name}")).style(base), name_area);
if let Some(position) = position {
frame.render_widget(
Paragraph::new(Line::from(vec![
Span::styled("░▓", edge),
Span::styled(position, badge),
]))
.style(base),
cursor,
);
}
frame.render_widget(
Paragraph::new(Line::from(vec![
Span::styled("░▓", edge),
Span::styled(position, badge),
]))
.style(base),
cursor,
);
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
@@ -1198,6 +1194,28 @@ mod tests {
Ok(())
}
#[test]
fn unavailable_position_keeps_its_badge_even_in_a_narrow_bar() -> Result<()> {
let mut terminal = ratatui::Terminal::new(ratatui::backend::TestBackend::new(7, 6))?;
terminal.draw(|frame| {
let [top, _, bottom] = shell_areas(frame.area());
draw_bars(
frame,
top,
bottom,
"SQLite",
"long database name",
false,
None,
);
})?;
let footer: String = (0..7)
.map(|x| terminal.backend().buffer()[(x, 5)].symbol())
.collect();
assert_eq!(footer, "░▓ N/A ");
Ok(())
}
#[test]
fn explorer_keeps_relations_under_the_connected_database() {
use ExplorerEntry::{Database as Db, Relation as Rel};
+1
View File
@@ -49,6 +49,7 @@ Navigation:
Full-width bars show dbdash/provider/READ ONLY above and mode/database below.
Only badges have colored backgrounds; the remaining bar area uses terminal defaults.
Focused inputs show one-based line:column (Unicode characters, not screen cells).
The position badge shows N/A outside focused inputs, including in info/help popups.
The query editor sits above rows/results; the explorer spans both panes.
Explorer and rows/schema bottom borders align; table names appear in the
top-right border, with page/column status below. Read errors appear above the query editor.