Public: anyone can read this; the crew can change it.

A check's summary, test row and error line are cut with `clip`, so a failing test named with an emoji reads whole #6764

opened this

Merged 39d 6h ago, live in production

The four places that shorten the lines explaining a red check now all call clip from src/text/clip.ts, and their own cutting code is gone. Before, they cut by UTF-16 position (slice), which could split an emoji at the limit and leave a lone surrogate. Now the cut always falls between whole code points.

Notes

opened this

The four places that shorten the lines explaining a red check now all call clip from src/text/clip.ts, and their own cutting code is gone. Before, they cut by UTF-16 position (slice), which could split an emoji at the limit and leave a lone surrogate. Now the cut always falls between whole code points.

  • src/checks/words.ts: oneLine now returns clip(text, LINE_MAX) (80).
  • src/checks/tests-row.ts: bound is now clip(text, LINE_MAX) (200). It shortens both pinned failure names and their output lines.
  • src/checks/summary.ts: truncate is now clip(text, SUMMARY_MAX) (200). The fallback summary is still not cut, as before.
  • src/runs/error_line.ts: firstErrorLine returns clip(text, ERROR_LINE_MAX) (120).

Behaviour changes to look at: clip collapses runs of whitespace to one space and counts length in code points. So a pinned failure line or error line that had aligned columns now shows single spaces. Lines with emoji may also keep a few more UTF-16 units than before. Existing tests don't depend on either.

New test: test/text-clip-checks.test.ts gives firstErrorLine a 300-character line with an emoji straddling the 120 limit. It checks there is no lone surrogate and that the result is 120 code points ending in …. It does the same for oneLine, a pinned failure name, and a summary. All four cases fail on main.

Tests run: the ten test files that import these modules, plus the new one. Two tests in test/looks.test.ts fail ("a real capture through the grant door" and "a dark capture is truly dark"). They fail the same way on main, so this change doesn't cause them. Everything else passes, and bun x tsc --noEmit is clean.

I made no other changes.

🤖 Generated with Claude Code

Closes #6629

commented

The four places that shorten the lines explaining a red check now all call clip from src/text/clip.ts, and their own cutting code is gone. Before, they cut by UTF-16 position (slice), which could split an emoji at the limit and leave a lone surrogate. Now the cut always falls between whole code points.

  • src/checks/words.ts: oneLine now returns clip(text, LINE_MAX) (80).
  • src/checks/tests-row.ts: bound is now clip(text, LINE_MAX) (200). It shortens both pinned failure names and their output lines.
  • src/checks/summary.ts: truncate is now clip(text, SUMMARY_MAX) (200). The fallback summary is still not cut, as before.
  • src/runs/error_line.ts: firstErrorLine returns clip(text, ERROR_LINE_MAX) (120).

Behaviour changes to look at: clip collapses runs of whitespace to one space and counts length in code points. So a pinned failure line or error line that had aligned columns now shows single spaces. Lines with emoji may also keep a few more UTF-16 units than before. Existing tests don't depend on either.

New test: test/text-clip-checks.test.ts gives firstErrorLine a 300-character line with an emoji straddling the 120 limit. It checks there is no lone surrogate and that the result is 120 code points ending in …. It does the same for oneLine, a pinned failure name, and a summary. All four cases fail on main.

Tests run: the ten test files that import these modules, plus the new one. Two tests in test/looks.test.ts fail ("a real capture through the grant door" and "a dark capture is truly dark"). They fail the same way on main, so this change doesn't cause them. Everything else passes, and bun x tsc --noEmit is clean.

I made no other changes.

🤖 Generated with Claude Code

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs