fix: preserve discord chunk whitespace

This commit is contained in:
Peter Steinberger
2026-01-17 07:11:15 +00:00
parent 3a6ee5ee00
commit 86a46874da
3 changed files with 24 additions and 2 deletions

View File

@@ -76,8 +76,8 @@ function splitLongLine(
}
if (breakIdx <= 0) breakIdx = limit;
out.push(remaining.slice(0, breakIdx));
const brokeOnSeparator = breakIdx < remaining.length && /\s/.test(remaining[breakIdx]);
remaining = remaining.slice(breakIdx + (brokeOnSeparator ? 1 : 0));
// Keep the separator for the next segment so words don't get glued together.
remaining = remaining.slice(breakIdx);
}
if (remaining.length) out.push(remaining);
return out;