124fa6a4
Handle color-only render cells safely
a73x 2026-04-09 06:01
diff --git a/src/vt.zig b/src/vt.zig index eaedd7a..ba47fff 100644 --- a/src/vt.zig +++ b/src/vt.zig @@ -187,10 +187,7 @@ pub const Terminal = struct { self: *const Terminal, cell: ghostty_vt.RenderState.Cell, ) CellColors { const style: ghostty_vt.Style = switch (cell.raw.content_tag) { .bg_color_palette, .bg_color_rgb => cell.style, else => if (cell.raw.style_id != 0) cell.style else .{}, }; const style: ghostty_vt.Style = if (cell.raw.style_id != 0) cell.style else .{}; const colors = self.render_state.colors; const fg = style.fg(.{ .default = colors.foreground, @@ -357,6 +354,24 @@ test "Terminal applies OSC 11 background color updates" { ); } test "Terminal resolves color-only cells without reading undefined style state" { var term = try Terminal.init(std.testing.allocator, .{ .cols = 80, .rows = 24, }); defer term.deinit(); term.write("\x1b[44m\x1b[K"); try term.snapshot(); const cell = term.render_state.row_data.get(0).cells.get(0); const colors = term.cellColors(cell); const palette = term.render_state.colors.palette; try std.testing.expectEqualDeep(rgbToFloat4(term.render_state.colors.foreground), colors.fg); try std.testing.expectEqualDeep(rgbToFloat4(palette[4]), colors.bg); } test "Terminal title callback fires on OSC 2" { var term = try Terminal.init(std.testing.allocator, .{ .cols = 80,