Skip to content

Make std help honor color_config and fix vertical padding - #19621

Merged
fdncred merged 8 commits into
nushell:mainfrom
ymcx:std-help-colors
Nov 22, 2026
Merged

fdncred merged 8 commits into
nushell:mainfrom
ymcx:std-help-colors

Conversation

@ymcx

@ymcx ymcx commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

Description

Now, instead of using hardcoded colors in std help, we retrieve them from $env.config.color_config. I did my best to match the keys to those of help, so that they would look somewhat similar when custom colors have been set.

I also adjusted the padding so that there would be no places with two lines of padding or no padding in between two sections.

(unrelated) While making this I noticed that the amount of indentation changes between each function. There are also some differences between the output of std help and help in terms of the sections we have and the way flags and stuff are rendered. While I did get them to match better, the diff became too large and it wouldn't at all have been in-scope for this PR, so I decided not to include them.

User-facing changes (Release notes)

std help now honors colors set in color_config and has the correct amount of padding.

Additional notes

Closes #12109

@github-actions github-actions Bot added the A:std-library Defining and improving the standard library written in Nu label Nov 20, 2026

@fdncred fdncred left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review overview

🟡 Changes recommended

Theme colors work for plain names, hex strings and {fg, attr} records, and the spacing is even on every page I checked. One kind of theme value sends help to man, and a few spots still don't match help.

Findings: 1 High severity · 0 Medium severity · 4 Low severity

Open (5)

Notes from my clanker, checked on 42eb470. Built the branch and ran each case on it and on 0.117.1 (ca70639, current main). Compared the plain-text pages for 15 commands plus alias, module and operator pages. Patched a copy of std/help to check the fixes in the first four threads. CI's Test Std step (test_help.nu) passed on this head; I didn't rerun it.

Comment thread crates/nu-std/std/help/mod.nu Resolved
Comment thread crates/nu-std/std/help/mod.nu Resolved
Comment thread crates/nu-std/std/help/mod.nu Resolved
Comment thread crates/nu-std/std/help/mod.nu Resolved
Comment thread crates/nu-std/std/help/mod.nu Resolved
@fdncred

fdncred commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

Here's one more minor things that probably need to be changed.

When a code snippet in backticks can't be highlighted, std help uses the full shape_external style, background included. The built-in help uses only the foreground color.

@ymcx

ymcx commented Nov 21, 2026

Copy link
Copy Markdown
Contributor Author

When a code snippet in backticks can't be highlighted, std help uses the full shape_external style, background included.

Ok, I reverted the code so that default_dimmed is used instead. This is actually how it was before the agent suggested changing it to shape_external in the third recommended change. At the time I didn't know how I could test this color out, but now that I do, I tried it out on help commands is-redirected, and it indeed is rendered in default_dimmed and default_italic, not shape_external.

@fdncred

fdncred commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

I'm just not sure any of those will work on terminals that don't accept colors. I'm not saying they do or don't. I'm saying I don't know. config use-colors should know.

@ymcx

ymcx commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

I'm just not sure any of those will work on terminals that don't accept colors.

The function I created, colorize, uses config use-colors to determine if the string should be colored or not. I replaced each direct call to ansi with a call to this function, and because of this, any text derived from crates/nu-std/std/help/mod.nu should contain no colors if they're disabled. This includes italics and bold.

@fdncred
fdncred merged commit 594dd47 into nushell:main Nov 22, 2026
14 checks passed
@fdncred

fdncred commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Thanks

@github-actions github-actions Bot added this to the v0.118.0 milestone Nov 22, 2026
@fdncred fdncred added notes:fixes Noted in "Bug fixes" section notes:ready Indicates Ready for Release notes labels Nov 22, 2026
@ymcx
ymcx deleted the std-help-colors branch November 22, 2026 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A:std-library Defining and improving the standard library written in Nu notes:fixes Noted in "Bug fixes" section notes:ready Indicates Ready for Release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

std help does not honor theme for (at least) flags, parameters, and parameter types

2 participants