From 7cd2f65f5cb3578d2751ae31bcbcf44189879430 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 5 Aug 2026 14:28:56 -0700 Subject: [PATCH] terminal: color reset should set override to null, not default #12755 Reset previously copied the active default into the override. This is wrong, a reset should unset the override and defer back to the default. Reset foreground, background, and cursor colors now resolve through the current default while explicit OSC overrides remain unchanged across configuration updates. Set a configured background in the OSC 11 regression, assert OSC 111 clears its override, then change the default to verify the reset color follows it. --- src/terminal/color.zig | 2 +- src/terminal/stream_terminal.zig | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/terminal/color.zig b/src/terminal/color.zig index 1909ba2a0..c04e19e84 100644 --- a/src/terminal/color.zig +++ b/src/terminal/color.zig @@ -350,7 +350,7 @@ pub const DynamicRGB = struct { } pub fn reset(self: *DynamicRGB) void { - self.override = self.default; + self.override = null; } }; diff --git a/src/terminal/stream_terminal.zig b/src/terminal/stream_terminal.zig index 7bd2cb046..0b2940d1c 100644 --- a/src/terminal/stream_terminal.zig +++ b/src/terminal/stream_terminal.zig @@ -1673,6 +1673,9 @@ test "OSC 11 set and reset background color" { var s: Stream = .init(.{ .allocator = testing.allocator, .handler = .init(&t) }); defer s.deinit(); + const default: color.RGB = .{ .r = 0x10, .g = 0x20, .b = 0x30 }; + t.colors.background.default = default; + // Set background to green s.nextSlice("\x1b]11;rgb:00/ff/00\x1b\\"); const bg = t.colors.background.get().?; @@ -1682,7 +1685,13 @@ test "OSC 11 set and reset background color" { // Reset background s.nextSlice("\x1b]111\x1b\\"); - try testing.expect(t.colors.background.get() == null); + try testing.expectEqual(default, t.colors.background.get().?); + try testing.expectEqual(null, t.colors.background.override); + + // A reset color continues to follow later configuration changes. + const updated: color.RGB = .{ .r = 0x40, .g = 0x50, .b = 0x60 }; + t.colors.background.default = updated; + try testing.expectEqual(updated, t.colors.background.get().?); } test "OSC 12 set and reset cursor color" {