vt: fix test failures in render and key_encode

The colors_get function used structSizedFieldFits to guard the
palette copy, which required the entire palette array to fit in the
provided size. This prevented partial palette writes when the caller
passed a truncated sized struct, since the guard failed even though
the inner code already handled partial copies correctly. Remove the
outer guard so the existing partial-copy logic applies.

The setopt_from_terminal test expected alt_esc_prefix to be false on
a fresh terminal, but the mode definition in modes.zig sets its
default to true. Update the test expectation to match.
This commit is contained in:
Mitchell Hashimoto
2026-03-23 09:23:11 -07:00
parent f92bb74196
commit 3c8d0a9c25
2 changed files with 2 additions and 6 deletions

View File

@@ -259,7 +259,7 @@ test "setopt_from_terminal" {
// Options should reflect defaults from a fresh terminal
try testing.expect(!e.?.opts.cursor_key_application);
try testing.expect(!e.?.opts.alt_esc_prefix);
try testing.expect(e.?.opts.alt_esc_prefix);
try testing.expectEqual(KittyFlags.disabled, e.?.opts.kitty_flags);
try testing.expectEqual(OptionAsAlt.false, e.?.opts.macos_option_as_alt);
}

View File

@@ -337,11 +337,7 @@ pub fn colors_get(
out_colors.cursor_has_value = colors.cursor != null;
}
if (lib.structSizedFieldFits(
Colors,
out_size,
"palette",
)) {
{
const palette_offset = @offsetOf(Colors, "palette");
if (out_size > palette_offset) {
const available = out_size - palette_offset;