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:
@@ -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", () => {
|
||||
|
||||
@@ -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") {
|
||||
|
||||
Reference in New Issue
Block a user