fix: always place at least one word on each line in reflow

This commit is contained in:
CJ van den Berg 2026-02-01 20:48:42 +01:00
parent 4898f02570
commit 0251d783bf
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -27,7 +27,7 @@ pub fn reflow(allocator: std.mem.Allocator, text: []const u8, width: usize) erro
continue :blk .words;
},
.words => {
if (line_len + word.len + 1 >= width - 1) {
if (line_len > prefix.len and line_len + word.len + 1 >= width - 1) {
try writer.writeByte('\n');
line_len = 0;
continue :blk .begin;