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" {