From 31efa90a87635019ccd8430229091e6bdba89399 Mon Sep 17 00:00:00 2001 From: Developer Date: Fri, 15 May 2026 23:12:52 +0800 Subject: [PATCH] fix(reader): skip leading newlines after page split to prevent blank top/bottom --- src/reader.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/reader.rs b/src/reader.rs index 6a35459..c1afb5a 100644 --- a/src/reader.rs +++ b/src/reader.rs @@ -438,11 +438,17 @@ pub fn calculate_pages(text: &str, chars_per_line: usize, lines_per_page: usize) split = i; } if split < total { - pages.push(split); - page_start = split; - line_count = 0; - line_pos = 0; - i = split; + // Skip leading newlines to prevent starting page with blank line + while split < total && chars[split] == '\n' { + split += 1; + } + if split < total { + pages.push(split); + page_start = split; + line_count = 0; + line_pos = 0; + i = split; + } } } }