Skip to content

refactor(styling): end bash-gutter lines at their content, not a reopened dim - #3056

Merged
max-sixty merged 2 commits into
mainfrom
fix-gutter-dim-bleed
Jun 12, 2026
Merged

max-sixty merged 2 commits into
mainfrom
fix-gutter-dim-bleed

Conversation

@max-sixty

@max-sixty max-sixty commented Jun 12, 2026 •

Copy link
Copy Markdown
Owner

Dispatched to fix a reported ANSI dim-bleed after bash-gutter blocks: in committed snapshots, multi-command hook announcements appear to inherit an unclosed [2m from the preceding gutter line (e.g. post_start_named_commands.snap, where the gutter line ends 'Installing deps'[0m[2m).

Diagnosis: the bleed doesn't exist in real output. Fresh cat -v captures of wt hook pre-merge --yes and wt switch --create with two-key hook tables show every gutter line closing with a full [0m, and later ◎ Running … lines rendering un-dimmed. The snapshots are misleading by construction: the cross-platform filter in tests/common/mod.rs deletes every line-final [0m before snapshotting, and the formatter reopens dim after the last highlight token before its per-line reset, so filtered snapshots end [0m[2m and read exactly like a dangling dim.

The change removes that misleading byte pattern at the source: phase 2 of format_bash_with_gutter_impl strips the no-op reopened dim (and the lone dim on blank lines) before appending each line's closing reset. Rendering is identical; lines now end at their content plus one reset.

Also bundled:

  • A CAUTION comment on the reset-stripping snapshot filter, so future readers don't diagnose SGR bleed from .snap bytes.
  • config_show_theme now binds the standard env redactions; regenerating its snapshot leaked a host LLVM_PROFILE_FILE path and tripped test_no_host_specific_paths_in_snapshots (pre-existing gap, invisible until regeneration since insta never compares info: blocks).
  • 108 regenerated snapshots. Verified mechanically: ANSI-stripped bodies are byte-identical; raw diffs are confined to line-end SGR sequences plus stale env: header refreshes (RUST_LOG: warn from an older harness).

Possible follow-up, not done here: the line-final-reset filter itself may be vestigial (anstream pass-through suggests piped output is identical across platforms now); removing it would make snapshots byte-truthful but churns nearly every snapshot and needs Windows CI to confirm.

The first Windows CI run caught a real latent bug the strip exposed: askama strips a template's final newline, so on a CRLF checkout (Windows autocrlf) the fish wrapper render ends with a lone \r that the formatter's pair-wise CRLF normalization missed. The \r reached tree-sitter and came back as a trailing token after the highlight closed, defeating the end-of-line cleanup (and historically invisible because insta trims trailing whitespace when comparing). Fixed by trimming trailing \r in the formatter's normalization, plus templates/* text eol=lf in .gitattributes since CRLF templates embedded at compile time would leak \r into the shell code Windows-built binaries emit at runtime.

🤖 Generated with Claude Code

This was written by Claude Code on behalf of max

…ened dim

format_bash_with_gutter reopened the dim base style after the last
highlight token on each line ([0m[2m), immediately followed by the
line's closing reset. Rendering was unaffected ([0m[2m[0m nets to a
full reset), but committed snapshots hide line-final resets (the
cross-platform filter in tests/common/mod.rs strips them), so gutter
lines in .snap files ended [0m[2m and read as a dangling dim bleeding
into the following announcement line. Strip the no-op tail in phase 2
so lines end at their content plus one closing reset.

Also:

- comment the snapshot filter that strips line-final resets, warning
  against diagnosing SGR bleed from .snap bytes
- bind standard env redactions in config_show_theme: regenerating its
  snapshot leaked a host LLVM_PROFILE_FILE path and tripped
  test_no_host_specific_paths_in_snapshots
- regenerate 108 snapshots; ANSI-stripped bodies are byte-identical,
  diffs are confined to line-end SGR sequences and stale env headers

Co-Authored-By: Claude Fable 5 <[email protected]>
The Windows test run caught the fish wrapper preview ending in a lone
\r: askama strips a template's final newline, so on a CRLF checkout
(autocrlf) the render ends `end\r`. The formatter's CRLF normalization
only replaced \r\n pairs, so the \r reached tree-sitter, came back as a
trailing token after the highlight closed, and defeated the end-of-line
SGR cleanup — invisible historically because insta trims trailing
whitespace when comparing snapshots. Trim trailing \r alongside \n.

Also force LF checkout for templates/* in .gitattributes: the templates
are embedded into the binary at compile time, so a CRLF checkout leaks
\r into the shell code Windows-built binaries emit at runtime.

Co-Authored-By: Claude Fable 5 <[email protected]>
@max-sixty
max-sixty merged commit f2a8cb6 into main Jun 12, 2026
35 checks passed
@max-sixty
max-sixty deleted the fix-gutter-dim-bleed branch June 12, 2026 06:38
max-sixty added a commit that referenced this pull request Jun 14, 2026
The two wide colored-table snapshots were captured before merging main and
missed two cosmetic changes the merge introduced: the per-row trailing
ANSI reset (#3056/#3061) and dropped empty-valued env-header entries
(#3037/#3063). Table content is unchanged; only the line-final `\x1b[0m`
and the snapshot env block differ, matching every other wide list snapshot.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants