Skip to content

fix: respect disabled colors when dimming bars - #651

Open
spicysharkco wants to merge 1 commit into
bootandy:masterfrom
spicysharkco:fix/dim-no-colors
Open

spicysharkco wants to merge 1 commit into
bootandy:masterfrom
spicysharkco:fix/dim-no-colors

Conversation

@spicysharkco

Copy link
Copy Markdown

With --dim, or dim = true in the config file, the percent bar is painted dark grey even when colors are off. Colors are off with -c, with NO_COLOR set, or when stdout is not a terminal. Piping the output to a file or to less then shows ESC[90m and ESC[0m around the bar, while sizes and names stay plain:

$ dust --dim -d 0 tests/test_dir | grep -c $'\e'
1
$ dust -d 0 tests/test_dir | grep -c $'\e'
0

The first command should print 0, like the second. The -c help says "No colors will be printed".

The dim branch checks only dim. The size and name painters check colors_on before painting. The fix makes the bar check it too. With -C, the bar is still dimmed.

test_dim_bars_respect_color_setting in src/display.rs covers the four dim/colors_on pairs. cargo test --locked test_dim_bars_respect_color_setting failed 3 of 3 runs before the fix and passed 3 of 3 after it.

With --dim, or dim = true in the config file, the percent bar was
painted dark grey even when colors were off: with -c, with NO_COLOR
set, or when stdout is not a terminal. Piped output then had ESC[90m
and ESC[0m around the bar, while sizes and names stayed plain.

Check colors_on before dimming the bar, as the size and name painters
already do. With -C the bar is still dimmed.
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.

1 participant