Skip to content

fix(colors): keep the number format when resetting colors - #682

Merged
sirmalloc merged 1 commit into
sirmalloc:mainfrom
eric-engberg:fix/color-reset-keeps-number-format
Oct 9, 2026
Merged

sirmalloc merged 1 commit into
sirmalloc:mainfrom
eric-engberg:fix/color-reset-keeps-number-format

Conversation

@eric-engberg

Copy link
Copy Markdown
Contributor

What

Edit Colors' (r)eset and (c)lear all now reset only colors, bold and dim. A widget's number style (set with . in Edit Lines, or decimals in settings.json) stays.

Why

Number styles started out in Edit Colors (#456's first commit cycled them with n there) and the two reset paths were extended to clear them too. Later in the same PR the cycle moved to Edit Lines ("The color menu goes back to color, bold and dim only"), but reset and clear all kept removing numberFormat.

So resetting a widget's colors also undid its number style, with nothing on screen saying so: the key help just says (r)eset in a colors menu, and the clear-all confirmation says "This will reset all colors for all widgets to their defaults." With Context Length set to whole numbers, Edit Colors → ↓ to Context Length → r: the preview goes from Ctx: 19k to Ctx: 18.6k, and after ctrl+s the widget is saved as {"id": "3", "type": "context-length"}, with its numberFormat gone.

How

resetWidgetStyling and clearAllWidgetStyling no longer list numberFormat among the fields they remove. They still remove color, backgroundColor, bold and dim as before. Widgets without a number style are unaffected, and the global number format in Global Overrides was never touched by these keys.

Demo

Context Length set to whole numbers (the preview's sample data, 19k), then Edit Colors → Context Length → r. Before, the number goes back to 18.6k along with the color; after, only the color resets.

Powerline: before

Reset turns Ctx 19k back into 18.6k, Powerline mode, before the fix

Powerline: after

Reset keeps Ctx at 19k, Powerline mode, after the fix

Plain: before

Reset turns Ctx 19k back into 18.6k, plain mode, before the fix

Plain: after

Reset keeps Ctx at 19k, plain mode, after the fix

Testing

  • The two existing tests in color-menu/__tests__/mutations.test.ts asserted that numberFormat was removed; they now expect it kept, alongside the color, bold and dim removal they already checked. Both failed before the fix.
  • bun test: 2782 pass, 0 fail. bun run lint passes.
  • The changed test file under Node 26.10.0 (Vitest): 7 pass.
  • Built CLI under Node 26.10.0 in tmux with a scratch HOME, the steps above: main shows Ctx: 18.6k after r and saves the widget without numberFormat; this branch keeps Ctx: 19k and saves "numberFormat": {"style": "whole"}, with the color reset to the default (Bright Black) on both.
  • Bun 1.4.2.

Edit Colors' (r)eset and (c)lear all removed each widget's numberFormat
along with its colors, bold and dim. Precision used to be cycled from Edit
Colors, but it moved to Edit Lines (the `.` key), and the reset paths kept
clearing it. So resetting a widget's colors silently undid its number
style: a Context Length set to whole numbers went from `Ctx: 19k` back to
`Ctx: 18.6k`, though neither the key help nor the clear-all confirmation
mentions anything but colors.

Reset and clear all now remove only color, background, bold and dim.
@sirmalloc
sirmalloc merged commit dfa54ba into sirmalloc:main Oct 9, 2026
3 checks passed
@eric-engberg
eric-engberg deleted the fix/color-reset-keeps-number-format branch October 9, 2026 22:23
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