fix(tui): handle CRLF and CR line endings (#6764)

This commit is contained in:
Xiangzhe
2026-07-17 15:01:10 +08:00
committed by GitHub
parent 216e672e7c
commit 00b032676f
2 changed files with 21 additions and 1 deletions
+20
View File
@@ -101,6 +101,26 @@ describe("wrapTextWithAnsi", () => {
});
describe("basic wrapping", () => {
it("should handle LF, CRLF, and CR line endings", () => {
assert.deepStrictEqual(wrapTextWithAnsi("first\nsecond\r\nthird\rfourth", 80), [
"first",
"second",
"third",
"fourth",
]);
});
it("should preserve ANSI state across CRLF and CR line endings", () => {
const red = "\x1b[31m";
const reset = "\x1b[0m";
assert.deepStrictEqual(wrapTextWithAnsi(`${red}first\r\nsecond\rthird${reset}`, 80), [
`${red}first`,
`${red}second`,
`${red}third${reset}`,
]);
});
it("should wrap plain text correctly", () => {
const text = "hello world this is a test";
const wrapped = wrapTextWithAnsi(text, 10);