Track strikethrough (SGR 9) so it is not dropped across highlighted tokens - #4015
Merged
Merged
Conversation
…okens The `Attributes` ANSI style tracker in `src/vscreen.rs` declares, initializes, clears (in `sgr_reset`), and re-emits (in `Display`) a `strike` field documented as `ON: ^[9m / OFF: ^[29m`, but `update_with_sgr()` had no match arm for SGR 9 (set strikethrough) or 29 (clear strikethrough). As a result `strike` was only ever cleared, never set. Because bat re-applies the tracked input ANSI style before each highlighted text run (nu_ansi_term appends a full reset after every token), attributes that are tracked — bold, dim, italic, underline — survive across tokens, while strikethrough was silently dropped after the first token. This path is active by default (`--strip-ansi`/`--sanitize` default to `never`). Add the missing `9` and `29` arms, mirroring the sibling underline (4/24) and italic (3/23) arms, so strikethrough is tracked and re-emitted like every other supported attribute. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
mikehasa
force-pushed
the
fix/track-strikethrough-sgr9
branch
from
September 22, 2026 12:15
5316c1d to
156ef1d
Compare
Contributor
Author
|
Thanks for the review and merge, @keith-hall! 🙏 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
src/vscreen.rstracks the terminal's active ANSI style in anAttributesstruct so bat can re-apply it before each syntax-highlighted token (nu_ansi_term appends a full\x1B[0mreset after every token). The struct already has astrikefield, documentedON: ^[9m / OFF: ^[29m, that is initialized, cleared insgr_reset(), and re-emitted inDisplay— butupdate_with_sgr()had no match arm for SGR9or29, sostrikewas only ever cleared, never set.Consequence: with ANSI passthrough (the default —
--strip-ansiand--sanitizeboth default tonever), bold/dim/italic/underline survive across highlighted tokens because they are tracked and re-emitted, but strikethrough visibly disappears after the first token.This adds the missing
9(set) and29(clear) arms, mirroring the sibling underline (4/24) and italic (3/23) arms, so strikethrough persists like every other supported attribute. Two-line behavioral change; no API change.to_reset_sequence()intentionally does not reset SGR attributes yet (existing commented-out TODO), sostrikeis handled there exactly like bold/italic — no change needed.Test Plan
cargo test(unit + integration).test_sgr_attributes_do_not_leak_into_wrong_fieldunit test to include SGR9, and addedtest_sgr_strike_is_tracked_and_clearedcovering set (9) and clear (29).ansi_sgr_strike_joins_attributes_when_wrapped, modeled on the existingansi_sgr_joins_attributes_when_wrapped, asserting strikethrough is re-emitted across a wrap boundary. It fails before the fix and passes after.Developed with assistance from Claude Code; reviewed & validated by me.
🤖 Generated with Claude Code