[READ-ONLY] Mirror of https://github.com/bombshell-dev/tty. Platform independent 2D layout engine for terminal applications based on Clay
5

Configure Feed

Select the types of activity you want to include in your feed.

test: failing repro for translate

Nate Moore (Jun 4, 2026, 8:35 PM -0500) a650b037 d75fb4b6

+40
+40
test/translate.test.ts
··· 1 + import { describe, expect, it } from "./suite.ts"; 2 + import { createTerm } from "../term.ts"; 3 + import { close, fixed, open, text } from "../ops.ts"; 4 + import { print } from "./print.ts"; 5 + 6 + const decode = (b: Uint8Array) => new TextDecoder().decode(b); 7 + 8 + describe("translate", () => { 9 + it("shifts the element visually but keeps its flow slot", async () => { 10 + let term = await createTerm({ width: 5, height: 1 }); 11 + // PROPOSED layout.translate: a post-layout visual shift that does NOT remove 12 + // the element from flow (CSS translate). Cast so it type-checks today; the 13 + // field is dropped at runtime against the current build. 14 + let res = term.render([ 15 + open("row", { layout: { width: fixed(5), direction: "ltr" } }), 16 + open("a", { layout: { translate: { x: 2, y: 0 } } as never }), 17 + text("A"), 18 + close(), 19 + text("B"), 20 + close(), 21 + ]); 22 + // pins: "a" reserves its flow slot at x=0, then renders shifted +2 -> x=2 23 + expect(res.info.get("a")!.bounds.x).toBe(2); 24 + }); 25 + 26 + it("does not let the sibling reflow into the translated element's slot", async () => { 27 + let term = await createTerm({ width: 5, height: 1 }); 28 + let res = term.render([ 29 + open("row", { layout: { width: fixed(5), direction: "ltr" } }), 30 + open("a", { layout: { translate: { x: 2, y: 0 } } as never }), 31 + text("A"), 32 + close(), 33 + text("B"), 34 + close(), 35 + ]); 36 + // pins: sibling "B" stays at its flow column 1 and "A" draws at column 2, 37 + // so the full row reads " BA" (not "B A", which removing-from-flow produces) 38 + expect(print(decode(res.output), 5, 1)).toBe(" BA "); 39 + }); 40 + });