fix: put plugin descriptions under source

This commit is contained in:
Peter Steinberger
2026-01-23 04:02:36 +00:00
parent e750ad5e75
commit d23c4a3f10
3 changed files with 45 additions and 23 deletions

View File

@@ -84,4 +84,21 @@ describe("renderTable", () => {
throw new Error(`Unexpected escape sequence at index ${i}`);
}
});
it("respects explicit newlines in cell values", () => {
const out = renderTable({
width: 48,
columns: [
{ key: "A", header: "A", minWidth: 6 },
{ key: "B", header: "B", minWidth: 10, flex: true },
],
rows: [{ A: "row", B: "line1\nline2" }],
});
const lines = out.trimEnd().split("\n");
const line1Index = lines.findIndex((line) => line.includes("line1"));
const line2Index = lines.findIndex((line) => line.includes("line2"));
expect(line1Index).toBeGreaterThan(-1);
expect(line2Index).toBe(line1Index + 1);
});
});

View File

@@ -93,15 +93,9 @@ function wrapLine(text: string, width: number): string[] {
const lines: string[] = [];
const isBreakChar = (ch: string) =>
ch === " " ||
ch === "\t" ||
ch === "\n" ||
ch === "\r" ||
ch === "/" ||
ch === "-" ||
ch === "_" ||
ch === ".";
ch === " " || ch === "\t" || ch === "/" || ch === "-" || ch === "_" || ch === ".";
const isSpaceChar = (ch: string) => ch === " " || ch === "\t";
let skipNextLf = false;
const buf: Token[] = [];
let bufVisible = 0;
@@ -149,6 +143,15 @@ function wrapLine(text: string, width: number): string[] {
}
const ch = token.value;
if (skipNextLf) {
skipNextLf = false;
if (ch === "\n") continue;
}
if (ch === "\n" || ch === "\r") {
flushAt(buf.length);
if (ch === "\r") skipNextLf = true;
continue;
}
if (bufVisible + 1 > width && bufVisible > 0) {
flushAt(lastBreakIndex);
}