From 563a719f03f614987b5c6babd435cdb86f4d0bc9 Mon Sep 17 00:00:00 2001 From: Christoph Ortenburg Date: Mon, 19 Oct 2026 14:48:31 -0400 Subject: [PATCH] fix(ui): the page tooltip stays in range on an empty document (#2834) Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/chrome.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/chrome.rs b/crates/ui-egui/src/chrome.rs index e1ff1f4b6d..dc26549cc3 100644 --- a/crates/ui-egui/src/chrome.rs +++ b/crates/ui-egui/src/chrome.rs @@ -758,8 +758,9 @@ pub fn right_rail(app: &mut PdfCraftApp, ui: &mut egui::Ui) { if widgets::text_width(ui, &position, &font) > ui.available_width() { position = page_count.to_string(); } - let of = - crate::i18n::fmt(tl!("Page {p} of {n}"), &[("p", &view.current.saturating_add(1).to_string()), ("n", &page_count.to_string())]); + // Out of range (an empty document), like `page_position`: "Page 0 of 0", never past the end. + let shown = if view.current < page_count { view.current + 1 } else { page_count }; + let of = crate::i18n::fmt(tl!("Page {p} of {n}"), &[("p", &shown.to_string()), ("n", &page_count.to_string())]); ui.label(egui::RichText::new(position).font(font).color(t.text_muted)).on_hover_text(of); let page_input_id = view.page_input_id(); // Consume replacement selection once, including when the editor has lost focus.