fix(reader): skip leading newlines after page split to prevent blank top/bottom

This commit is contained in:
Developer
2026-05-15 23:12:52 +08:00
parent 7602121fda
commit 31efa90a87

View File

@@ -438,11 +438,17 @@ pub fn calculate_pages(text: &str, chars_per_line: usize, lines_per_page: usize)
split = i; split = i;
} }
if split < total { if split < total {
pages.push(split); // Skip leading newlines to prevent starting page with blank line
page_start = split; while split < total && chars[split] == '\n' {
line_count = 0; split += 1;
line_pos = 0; }
i = split; if split < total {
pages.push(split);
page_start = split;
line_count = 0;
line_pos = 0;
i = split;
}
} }
} }
} }