fix(tui): cap portrait image render height

This commit is contained in:
Mario Zechner
2026-05-13 16:11:40 +02:00
parent c00f1cf130
commit e3faf41801
4 changed files with 82 additions and 12 deletions

View File

@@ -312,6 +312,40 @@ describe("Kitty image cursor movement", () => {
}
});
it("honors maxHeightCells by reducing rendered width", () => {
setCapabilities({ images: "kitty", trueColor: true, hyperlinks: true });
setCellDimensions({ widthPx: 10, heightPx: 10 });
try {
const result = renderImage("AAAA", { widthPx: 10, heightPx: 100 }, { maxWidthCells: 10, maxHeightCells: 5 });
assert.ok(result);
assert.strictEqual(result.rows, 5);
assert.ok(result.sequence.includes(",c=1,r=5"));
} finally {
resetCapabilitiesCache();
setCellDimensions({ widthPx: 9, heightPx: 18 });
}
});
it("caps Image component height to a square pixel box by default", () => {
setCapabilities({ images: "kitty", trueColor: true, hyperlinks: true });
setCellDimensions({ widthPx: 10, heightPx: 20 });
try {
const image = new Image(
"AAAA",
"image/png",
{ fallbackColor: (value) => value },
{ maxWidthCells: 10 },
{ widthPx: 10, heightPx: 100 },
);
const lines = image.render(12);
assert.strictEqual(lines.length, 5);
assert.ok(lines[0].includes(",c=1,r=5"));
} finally {
resetCapabilitiesCache();
setCellDimensions({ widthPx: 9, heightPx: 18 });
}
});
it("places image sequence on first line with empty padding rows", () => {
setCapabilities({ images: "kitty", trueColor: true, hyperlinks: true });
setCellDimensions({ widthPx: 10, heightPx: 10 });