Skip to content

[BUG] display.percent.type "num" "num-color" together with padding produces wrong output #2364

@claudiofreitas

Description

@claudiofreitas

Read the FAQ first

  • I have checked the FAQ but the issue is not covered

Description

Reproduction details:

When the configuration contains display.percent.type including ["num", "num-color"], and the format contains a padding (> or <), the output doesn't display correctly.

My guess is that the padding is being calculated not based in the displayed string, but it is also considering the coloring characters.

I tried to find an existing report, but I wasn't able.

Version used

fastfetch 2.63.1 (x86_64)

Bug prevalence

Always

Regression

Not sure

Installation

Package manager

Package manager

nixpkgs (unstable)

Screenshots

I created a small config-bug.jsonc attached below that reproduces the issue.

In the screenshot below, the first Memory module uses {percentage>3} which I expected to be displayed as 84% which are exactly 3 characters. Instead it erases "84%) | 26.02 G" string that was supposed to be displayed.

The second Memory module uses {percentage}, which displays the correct colored number.

Image

Configuration

{
	"$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json",
	"logo": {
		"type": "none"
	},
	"display": {
    "separator": "",
    "brightColor": false,
		"percent": {
			"type": ["bar", "num", "num-color"],
			"ndigits": 0,
			"color": {
				"green":"green",
				"yellow":"yellow",
				"red":"red"
			}
		},
		"bar": {
			"border": null,
			"char": {
				"elapsed": "",
				"total": ""
			},
			"width": 10
		}
	},
	"modules": [
		{
			"type": "memory",
			"key": "  Memory   ",
			"keyColor": "blue",
			"format": "{percentage-bar} ({percentage>3})  {used>9} of {total>9}",
			"percent": {
				"green": 30,
				"yellow": 70
			}
		},
		{
			"type": "memory",
			"key": "  Memory   ",
			"keyColor": "blue",
			"format": "{percentage-bar} ({percentage})  {used} of {total}",
			"percent": {
				"green": 30,
				"yellow": 70
			}
		}
	]
}

System information

I do not feel comfortable sharing this amount of information.
If the provided information in the previous fields is not enough to help in the reproducibility and troubleshoot, let me know and I can provide specific individual information instead of the full output.

Features built-in

fastfetch --list-features
threads
vulkan
wayland
xcb-randr
xrandr
gio
dconf
eet
dbus
imagemagick7
chafa
zlib
sqlite3
egl
glx
opencl
libpulse
libddcutil
libelf
System yyjson
linux/videodev2

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions