From 254072e65625189ca23badccc5dcb3035fe2a46c Mon Sep 17 00:00:00 2001 From: "Jeffrey C. Ollie" Date: Sat, 17 Aug 2024 15:34:35 -0500 Subject: [PATCH] fix test error and improve error logging --- src/terminal/osc.zig | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/terminal/osc.zig b/src/terminal/osc.zig index 326766f6a..89bd8e976 100644 --- a/src/terminal/osc.zig +++ b/src/terminal/osc.zig @@ -1038,15 +1038,24 @@ pub const Parser = struct { switch (self.command) { .kitty_color_protocol => |*v| { if (kind == .key_only) { - v.list.append(.{ .reset = key }) catch unreachable; + v.list.append(.{ .reset = key }) catch |err| { + log.warn("unable to append kitty color protocol option: {}", .{err}); + return; + }; return; } if (value.len == 0) { - v.list.append(.{ .reset = key }) catch unreachable; + v.list.append(.{ .reset = key }) catch |err| { + log.warn("unable to append kitty color protocol option: {}", .{err}); + return; + }; return; } if (mem.eql(u8, "?", value)) { - v.list.append(.{ .query = key }) catch unreachable; + v.list.append(.{ .query = key }) catch |err| { + log.warn("unable to append kitty color protocol option: {}", .{err}); + return; + }; return; } v.list.append( @@ -1055,13 +1064,16 @@ pub const Parser = struct { .key = key, .color = RGB.parse(value) catch |err| switch (err) { error.InvalidFormat => { - log.err("invalid color format in kitty color protocol: {s}", .{value}); + log.warn("invalid color format in kitty color protocol: {s}", .{value}); return; }, }, }, }, - ) catch unreachable; + ) catch |err| { + log.warn("unable to append kitty color protocol option: {}", .{err}); + return; + }; return; }, else => {}, @@ -1636,7 +1648,7 @@ test "OSC: hyperlink end" { test "OSC: kitty color protocol" { const testing = std.testing; - var p: Parser = .{ .alloc = std.testing.allocator }; + var p: Parser = .{ .alloc = testing.allocator }; defer p.deinit(); const input = "21;foreground=?;background=rgb:f0/f8/ff;cursor=aliceblue;cursor_text;visual_bell=;selection_foreground=#xxxyyzz;selection_background=?;selection_background=#aabbcc";