fix: align wrap mode with Ink (trim: false)

Ink's wrap mode uses { trim: false } to preserve leading/trailing
whitespace on wrapped lines. We incorrectly used trim: true which
stripped whitespace. Updates unit test and inline snapshots.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Yunfei He
2026-05-25 23:14:17 +08:00
parent 630ee8488a
commit 07cfe5d6fb
3 changed files with 11 additions and 11 deletions
@@ -26,7 +26,7 @@ test("flattenLeaves recurses into virtual-text", () => {
});
test("wrapText splits on width", () => {
expect(wrapText("hello world", 5, "wrap")).toEqual(["hello", "world"]);
expect(wrapText("hello world", 5, "wrap")).toEqual(["hello", " ", "world"]);
});
test("wrapText truncate-end cuts with ellipsis", () => {
+1 -1
View File
@@ -21,7 +21,7 @@ export function wrapText(text: string, width: number, mode: WrapMode = "wrap"):
if (width <= 0) return [""];
if (mode === "wrap") {
return wrapAnsi(text, width, { hard: true, trim: true, wordWrap: true }).split("\n");
return wrapAnsi(text, width, { hard: true, trim: false }).split("\n");
}
if (mode === "hard") {