From 243d32c82a050fd356371d2122184b974b6e9ebd Mon Sep 17 00:00:00 2001 From: Jake Nelson Date: Mon, 17 Nov 2025 15:58:50 +1100 Subject: [PATCH] fix: ColorList.clone not cloning colors_c --- src/config/Config.zig | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/config/Config.zig b/src/config/Config.zig index 6469c333e..655fd0cc0 100644 --- a/src/config/Config.zig +++ b/src/config/Config.zig @@ -5203,6 +5203,7 @@ pub const ColorList = struct { ) Allocator.Error!Self { return .{ .colors = try self.colors.clone(alloc), + .colors_c = try self.colors_c.clone(alloc), }; } @@ -5281,6 +5282,26 @@ pub const ColorList = struct { try p.formatEntry(formatterpkg.entryFormatter("a", &buf.writer)); try std.testing.expectEqualSlices(u8, "a = #000000,#ffffff\n", buf.written()); } + + test "clone" { + const testing = std.testing; + var arena = ArenaAllocator.init(testing.allocator); + defer arena.deinit(); + const alloc = arena.allocator(); + + var source: Self = .{}; + try source.parseCLI(alloc, "#ff0000,#00ff00,#0000ff"); + + const cloned = try source.clone(alloc); + + try testing.expect(source.equal(cloned)); + try testing.expectEqual(source.colors_c.items.len, cloned.colors_c.items.len); + for (source.colors_c.items, cloned.colors_c.items) |src_c, clone_c| { + try testing.expectEqual(src_c.r, clone_c.r); + try testing.expectEqual(src_c.g, clone_c.g); + try testing.expectEqual(src_c.b, clone_c.b); + } + } }; /// Palette is the 256 color palette for 256-color mode. This is still