nushell / nushell/nu_scripts

Theme preview doesn't show "string" label when a closure is used in `color_config`

Open
#919 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Nushell
Stars
1.3k
Forks
323
Avg merge
2h 55m
Merged PRs (30d)
3

Description

Trying out an example from @fdncred where:

$env.config.color_config.string = {|x| if $x =~ '^#[a-fA-F\d]+' { $x } else { 'default' } 

If that's set in a theme, the theme preview small shows the closure, but doesn't label it as the string type. All the types with basic (or record) colors show the labels.

On the bright side, none of the current themes use a closure for anything other than date, filesize, and bool, and all of those expand their values instead of showing the closure value. Still, if someone has their color_config set like this, the theme preview will be off. Even if the label was shown properly, attempting to display the closure itself inside the table is going to be problematic from a formatting standpoint. Probably need a different solution here.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue by setting a closure in color_config.string and running theme preview small. Read the theme preview handling for closure-valued colors; done means the string label is represented correctly without trying to format the closure itself.

Written by the indexing model from the issue text.

Assessment

Tech stack
shell
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.