highlight: Also use the fallback variable if the main is empty#8793
Conversation
Currently, when a variable like $fish_color_command is set but empty:
set -g fish_color_command
what happens is that highlight parses it and ends up with a "normal"
color.
Change it so instead it sees that the variable is empty and goes
on to check the fallback variable, e.g. fish_color_normal.
That makes it easier to make themes that override variables.
This means that older themes that expect an empty variable to be
"normal" need to be updated to set it to "normal".
Following from this, we could make writing .theme files easier by no
longer requiring them to list all variables with specific values.
Either the theme reader could be updated to implicitly set known color
variables to empty, or the themes could feature empty values.
See fish-shell#8787.
| ========================================== ===================================================================== | ||
|
|
||
| If a variable isn't set, fish usually tries ``$fish_color_normal``, except for: | ||
| If a variable isn't set or is empty, fish usually tries ``$fish_color_normal``, except for: |
There was a problem hiding this comment.
sounds like a good idea (assuming that not too many themes rely on the empty=normal behavior)
I'm not sure how it enables themes to override variables but I didn't think very hard..
There was a problem hiding this comment.
What I mean by that is that this allows making a theme with only global variables, and it will override any potentially set universal variables.
So you can start by setting all variables to empty and then set the ones you want, you don't have to erase variables (which for uvars would be permanent).
assuming that not too many themes rely on the empty=normal behavior
Of our themes only the None theme uses any empty values, and that sets the fallback colors to normal anyway.
I don't imagine this is used much elsewhere because I don't think there is much demand for the "normal" color. Most themes, in my experience, look like dracula.fish - a fixed palette of RGB colors.
It's also very simple to fix: If you notice your theme colors being not-normal where you expected normal, simply add a "normal" where you had an empty value. This is even backwards-compatible, and it is more like what you would get with set_color.
set_color $fish_color_option $fish_color_param won't be normal only because $fish_color_option isn't set.
There was a problem hiding this comment.
sounds good, thanks. The new behavior is more intuitive
This allows keeping it to the fallback value, making us independent from the theme that was set before.
|
I just pushed commits that make That should make themes more self-contained and make it harder to accidentally inherit color from the previous theme. Specifically it'll be nicer when we add a color variable, because then it would be set to empty and the fallback would kick in even if the theme hasn't been updated. |
Currently, when a variable like $fish_color_command is set but empty:
what happens is that highlight parses it and ends up with a "normal"
color.
Change it so instead it sees that the variable is empty and goes
on to check the fallback variable, e.g. fish_color_normal.
That makes it easier to make themes that override variables.
This means that older themes that expect an empty variable to be
"normal" need to be updated to set it to "normal".
Following from this, we could make writing .theme files easier by no
longer requiring them to list all variables with specific values.
Either the theme reader could be updated to implicitly set known color
variables to empty, or the themes could feature empty values.
See #8787.
TODOs: