fix(tui): show [0/0] instead of [1/0] for empty files

This commit is contained in:
dailz
2026-04-11 08:52:22 +08:00
parent 6820246997
commit 3c042e20a1

View File

@@ -15,7 +15,12 @@ pub fn render(frame: &mut ratatui::Frame, app: &mut App) {
// ── Title bar ──────────────────────────────────────────────────
let title_text = if app.is_loaded() {
let name = app.file_name().unwrap_or("unknown");
format!(" {} [{}/{}]", name, app.cursor_line + 1, app.total_lines())
let cursor_display = if app.total_lines() == 0 {
0
} else {
app.cursor_line + 1
};
format!(" {} [{}/{}]", name, cursor_display, app.total_lines())
} else {
" Log Viewer".to_string()
};