diff --git a/docs/changelog.rst b/docs/changelog.rst index 9772c93ad..05055b0d2 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -261,6 +261,9 @@ Detailed list of changes arguments, such as non-numbers or NaN, as zero opacity instead of reporting an error +- Remote control: Fix ``kitten @ set-colors --reset`` failing on invalid + color arguments or missing configuration files instead of ignoring them + - ssh kitten: Fix hanging when re-using a shared connection whose connection to the server has silently died, for example, after a network change or suspend. Now the kitten detects this and reconnects (:iss:`10691`) diff --git a/tools/cmd/at/set_colors.go b/tools/cmd/at/set_colors.go index 2d77ab25a..631e670ac 100644 --- a/tools/cmd/at/set_colors.go +++ b/tools/cmd/at/set_colors.go @@ -294,6 +294,9 @@ func set_color_in_color_map(key, val string, ans map[string]any, check_nullable, func parse_colors_and_files(args []string) (map[string]any, error) { ans := make(map[string]any, len(args)) + if options_set_colors.Reset { + return ans, nil + } for _, arg := range args { key, val, found := strings.Cut(strings.ToLower(arg), "=") if found { diff --git a/tools/cmd/at/set_colors_test.go b/tools/cmd/at/set_colors_test.go new file mode 100644 index 000000000..8737efb88 --- /dev/null +++ b/tools/cmd/at/set_colors_test.go @@ -0,0 +1,51 @@ +// License: GPLv3 Copyright: 2026, kitty contributors + +package at + +import ( + "fmt" + "path/filepath" + "testing" + + "github.com/kovidgoyal/kitty/tools/utils" +) + +func TestSetColorsResetIgnoresArguments(t *testing.T) { + original_reset := options_set_colors.Reset + t.Cleanup(func() { options_set_colors.Reset = original_reset }) + missing_file := filepath.Join(t.TempDir(), "missing.conf") + for _, reset := range []bool{false, true} { + for _, test := range []struct { + name, arg string + invalid bool + }{ + {"invalid-color", "foreground=not-a-color", true}, + {"missing-file", missing_file, true}, + {"valid-color", "foreground=red", false}, + } { + t.Run(fmt.Sprintf("%s/reset=%t", test.name, reset), func(t *testing.T) { + options_set_colors.Reset = reset + io_data := rc_io_data{rc: &utils.RemoteControlCmd{}} + err := create_payload_set_colors(&io_data, nil, []string{test.arg}) + want_error := test.invalid && !reset + if (err != nil) != want_error { + t.Fatalf("expected error=%t, got: %v", want_error, err) + } + if err != nil { + return + } + payload := io_data.rc.Payload.(set_colors_json_type) + if payload.Reset != reset { + t.Fatalf("expected reset=%t, got: %#v", reset, payload) + } + if reset { + if len(payload.Colors) != 0 { + t.Fatalf("--reset did not ignore color arguments: %#v", payload.Colors) + } + } else if payload.Colors["foreground"] != uint32(0xff0000) { + t.Fatalf("foreground was not parsed: %#v", payload.Colors) + } + }) + } + } +}