Skip to content

fix: use targeted SGR reset for fg/bg colors#295

Open
mo1ein wants to merge 1 commit into
fatih:mainfrom
mo1ein:fix/underline-wrapping-colorized-strings
Open

fix: use targeted SGR reset for fg/bg colors#295
mo1ein wants to merge 1 commit into
fatih:mainfrom
mo1ein:fix/underline-wrapping-colorized-strings

Conversation

@mo1ein

@mo1ein mo1ein commented Jul 15, 2026

Copy link
Copy Markdown

Fixes #233

The unformat() function emitted \x1b[0m (full Reset) for foreground and background colors because they were missing from mapResetAttributes. This caused wrapping already-colorized strings with Underline to lose the underline — the inner \x1b[0m wiped out the outer formatting.

Fix by:

  • Adding all foreground colors (→ 39) and background colors (→ 49) to mapResetAttributes
  • Changing unformat() to skip params not in the map instead of defaulting to Reset (0), which also fixes compound RGB sequences where numeric sub-params would cause spurious full resets

The unformat() function emitted \x1b[0m (full Reset) for foreground
and background colors because they were missing from mapResetAttributes.
This caused wrapping already-colorized strings with Underline to lose
the underline — the inner \x1b[0m wiped out the outer formatting.

Fix by:
- Adding all foreground colors (→ 39) and background colors (→ 49)
  to mapResetAttributes
- Changing unformat() to skip params not in the map instead of
  defaulting to Reset (0), which also fixes compound RGB sequences
  where numeric sub-params would cause spurious full resets

Closes fatih#233
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.

Colorized string doesn't get underlined correctly

1 participant