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.
This commit is contained in:
Johannes Altmanninger
2025-11-25 12:52:39 +01:00
parent 66f6493fbf
commit dbdecaba6d
3 changed files with 0 additions and 65 deletions

View File

@@ -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])]