From dbdecaba6d1477c05992bf1320e7d19f4f75da88 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Tue, 25 Nov 2025 12:52:39 +0100 Subject: [PATCH] fish_config: remove hardcoded set of colors to erase This is incomplete, and we'll solve the problem differently. For now, leave colors that are not mentioned in the theme. This causes problems for sparse themes, but a following commit will fix that by making "fish_config theme choose" erase all variables set by a previous invocation (but not erase variables set by the user). Only webconfig won't do that since it (historically) uses copy semantics, but we could change that too if needed. This also breaks the guarantee mentioned by this comment in webconfig: > Ensure that we have all the color names we know about, so that if the > user deletes one he can still set it again via the web interface which should be fine because: 1. a following commit will always set all globals at interactive init, so colors should only be missing in edge cases ("fish -c fish_config"). 2. it's easy to recover from by setting a default theme. --- share/functions/__fish_color_variables.fish | 38 --------------------- share/functions/fish_config.fish | 13 ------- share/tools/web_config/webconfig.py | 14 -------- 3 files changed, 65 deletions(-) delete mode 100644 share/functions/__fish_color_variables.fish diff --git a/share/functions/__fish_color_variables.fish b/share/functions/__fish_color_variables.fish deleted file mode 100644 index b1ce47bc5..000000000 --- a/share/functions/__fish_color_variables.fish +++ /dev/null @@ -1,38 +0,0 @@ -# localization: skip(private) -function __fish_color_variables - printf %s "\ -fish_color_autosuggestion -fish_color_cancel -fish_color_command -fish_color_comment -fish_color_cwd -fish_color_end -fish_color_error -fish_color_escape -fish_color_host -fish_color_host_remote -fish_color_keyword -fish_color_normal -fish_color_operator -fish_color_option -fish_color_param -fish_color_quote -fish_color_redirection -fish_color_search_match -fish_color_selection -fish_color_user -fish_pager_color_background -fish_pager_color_completion -fish_pager_color_description -fish_pager_color_prefix -fish_pager_color_progress -fish_pager_color_secondary_background -fish_pager_color_secondary_completion -fish_pager_color_secondary_description -fish_pager_color_secondary_prefix -fish_pager_color_selected_background -fish_pager_color_selected_completion -fish_pager_color_selected_description -fish_pager_color_selected_prefix -" -end diff --git a/share/functions/fish_config.fish b/share/functions/fish_config.fish index 2700a2be7..5888745c1 100644 --- a/share/functions/fish_config.fish +++ b/share/functions/fish_config.fish @@ -19,7 +19,6 @@ function fish_config --description "Launch fish's web based configuration" if set -l python (__fish_anypython) function __fish_config_webconfig -V python -a web_config set -lx __fish_bin_dir $__fish_bin_dir - set -lx fish_color_variables "$(__fish_color_variables)" $python $web_config/webconfig.py end __fish_data_with_directory tools/web_config '.*' __fish_config_webconfig @@ -236,7 +235,6 @@ function __fish_config_theme_choose set scope -U end - set -l known_colors (__fish_color_variables) if not set -q argv[1] # We're persisting whatever current colors are loaded (maybe in the global scope) # to the universal scope, without overriding them from a theme file. @@ -272,17 +270,6 @@ function __fish_config_theme_choose set $scope $toks set -a defined_colors $toks[1] end - - # Set all colors that aren't mentioned to empty - for c in $known_colors - contains -- $c $defined_colors - and continue - # Erase conflicting global variables so we don't get a warning and - # so changes are observed immediately. - set -eg $c - set $scope $c - end - end function __fish_config_theme_canonicalize --no-scope-shadowing diff --git a/share/tools/web_config/webconfig.py b/share/tools/web_config/webconfig.py index 90ebbde1d..d09a4f531 100755 --- a/share/tools/web_config/webconfig.py +++ b/share/tools/web_config/webconfig.py @@ -41,8 +41,6 @@ import webbrowser if term is not None: os.environ["TERM"] = term -KNOWN_COLORS = set(os.environ["fish_color_variables"].splitlines()) - def find_executable(exe, paths=()): final_path = os.environ["PATH"].split(os.pathsep) @@ -804,11 +802,6 @@ class FishConfigHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): colors.sort(key=operator.itemgetter("name")) - # Ensure that we have all the color names we know about, so that if the - # user deletes one he can still set it again via the web interface - for color_name in KNOWN_COLORS - {color["name"] for color in colors}: - add_color(color_name, "") - info["colors"] = colors return info @@ -1199,20 +1192,13 @@ class FishConfigHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): if p == "/set_color/": print("# Colorscheme: " + postvars.get("theme")) - have_colors = set() output = "" for item in postvars.get("colors"): what = item.get("what") color = item.get("color") if what: - have_colors.add(what) output = self.do_set_color_for_variable(what, color) - # Set all known colors that weren't defined in this theme - # to empty, to avoid keeping around coloration from an earlier theme. - for what in KNOWN_COLORS - have_colors: - output += "\n" + self.do_set_color_for_variable(what, "") - elif p == "/get_function/": what = postvars.get("what") output = [self.do_get_function(what[0])]