fix(runtime): nest Text ANSI styles per-style in Ink's order (Ink parity, G68) (#65)
Ink's Text.tsx transform applies each enabled style as a SEPARATE nested chalk wrap, in the exact order dim -> color -> backgroundColor -> bold -> italic -> underline -> strikethrough -> inverse. vue-tui's applyChalk built ONE chained ChalkInstance (color -> bg -> dim -> bold -> ...) and invoked it once, producing a different, non-Ink byte sequence for any multi-style Text: e.g. color+bold emitted [31m[1mX[22m[39m vs Ink's [1m[31mX[39m[22m, and dim+bold dropped the bold re-open after dim's SGR-22 reset. Rewrite applyChalk to mirror Ink: apply each style as its own nested chalk(...) call in Ink's order, reusing the existing color/background resolution. Chalk level handling (FORCE_COLOR / level 0 -> no codes) is preserved and ANSI codes remain zero-width, so styled-text measurement is unchanged. Multi-style Text now produces byte-identical ANSI to Ink. Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -1340,7 +1340,7 @@ test("borderDimColor does not dim styled child Text touching left edge", async (
|
||||
);
|
||||
expect(lastFrame()).toMatchInlineSnapshot(`
|
||||
"[2m╭───────────╮[22m
|
||||
[2m│[22m[34m[1mstyled text[22m[39m[2m│[22m
|
||||
[2m│[22m[1m[34mstyled text[39m[22m[2m│[22m
|
||||
[2m╰───────────╯[22m"
|
||||
`);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user