Merge PR #7013: fix(tui): prevent UUID prefixes rendering color swatches (@roboomp)
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
|
||||
- Fixed native Windows terminal panes freezing their host during forced closure by skipping the impossible stdout-drain wait after ConPTY disconnects ([#6917](https://github.com/can1357/oh-my-pi/issues/6917)).
|
||||
- Fixed the `Loader` spinner pegging a CPU core during idle waits: advancing the braille glyph baked it into the underlying `Text` via `setText`, invalidating the wrap cache every 80 ms tick so `wrapTextWithAnsi` and per-line width measurement re-ran over the whole message. The wrapped text now carries a stable representative for each frame display width and only the visible glyph is swapped at render time, so same-width frames reuse the wrap/width pipeline while custom themes with mixed-width frames remain correctly wrapped ([#6940](https://github.com/can1357/oh-my-pi/issues/6940)).
|
||||
- Fixed hash-prefixed UUIDs in prose being misclassified as 8-digit CSS colors and receiving spurious swatches ([#7002](https://github.com/can1357/oh-my-pi/issues/7002)).
|
||||
|
||||
## [17.1.8] - 2026-07-28
|
||||
|
||||
|
||||
@@ -1284,11 +1284,12 @@ function collapseInlineHtml(tokens: Token[]): Token[] {
|
||||
const DEFAULT_COLOR_SWATCH_GLYPH = "■";
|
||||
|
||||
// `#` + 3-8 hex digits, not glued to a surrounding word/`#`/`&` (avoids HTML
|
||||
// entities like ☃ and paths like foo#fff) and not trailed by more hex
|
||||
// (so over-long runs never produce a misleading swatch). Length/letter rules
|
||||
// are enforced in classifyHexColor since the alternation can't express "exactly
|
||||
// 3, 6, or 8".
|
||||
const HEX_COLOR_REGEX = /(?<![\w#&])#([0-9a-fA-F]{3,8})(?![0-9a-fA-F])/g;
|
||||
// entities like ☃ and paths like foo#fff), not the start of a canonical
|
||||
// UUID, and not trailed by more hex (so over-long runs never produce a
|
||||
// misleading swatch). Length/letter rules are enforced in classifyHexColor
|
||||
// since the alternation can't express "exactly 3, 6, or 8".
|
||||
const HEX_COLOR_REGEX =
|
||||
/(?<![\w#&])#(?![0-9a-fA-F]{8}(?:-[0-9a-fA-F]{4}){3}-[0-9a-fA-F]{12})([0-9a-fA-F]{3,8})(?![0-9a-fA-F])/g;
|
||||
const HEX_COLOR_EXACT_REGEX = /^#([0-9a-fA-F]{3,8})$/;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1751,6 +1751,21 @@ describe("Inline color swatches", () => {
|
||||
expect(code.includes("■")).toBe(false);
|
||||
});
|
||||
|
||||
it("does not swatch hash-prefixed UUIDs in prose", () => {
|
||||
const uuid = new Markdown(
|
||||
"Use feedback ID #6635765d-4a44-4a5e-a536-a8b72b0395b5 for testing.",
|
||||
0,
|
||||
0,
|
||||
defaultMarkdownTheme,
|
||||
)
|
||||
.render(80)
|
||||
.join("");
|
||||
expect(uuid.includes("■")).toBe(false);
|
||||
|
||||
const color = new Markdown("Use color #6635765d.", 0, 0, defaultMarkdownTheme).render(80).join("");
|
||||
expect(color.includes(swatchFor("6635765d"))).toBeTruthy();
|
||||
});
|
||||
|
||||
it("uses the theme's colorSwatch symbol when provided", () => {
|
||||
const themed = { ...defaultMarkdownTheme, symbols: { ...defaultMarkdownTheme.symbols, colorSwatch: "▢" } };
|
||||
const out = new Markdown("Accent #C5FFD6.", 0, 0, themed).render(80).join("\n");
|
||||
|
||||
Reference in New Issue
Block a user