fix(kittygfx): accept commands with no control data (#7023)

This sort of command is treated as valid by Kitty so we should too. In
fact, it occurs with the example `send-png` script provided in the docs
for the protocol.
This commit is contained in:
Mitchell Hashimoto
2025-04-07 20:31:41 -07:00
committed by GitHub

View File

@ -98,6 +98,12 @@ pub const Parser = struct {
self.state = .control_value;
},
// This can be encountered if we have a sequence with no
// control data, only payload data (i.e. "\x1b_G;<data>").
//
// Kitty treats this as valid so we do as well.
';' => self.state = .data,
else => try self.accumulateValue(c, .control_key_ignore),
},
@ -1053,6 +1059,21 @@ test "delete command" {
try testing.expectEqual(@as(u32, 4), dv.y);
}
test "no control data" {
const testing = std.testing;
const alloc = testing.allocator;
var p = Parser.init(alloc);
defer p.deinit();
const input = ";QUFBQQ";
for (input) |c| try p.feed(c);
const command = try p.complete();
defer command.deinit(alloc);
try testing.expect(command.control == .transmit);
try testing.expectEqualStrings("AAAA", command.data);
}
test "ignore unknown keys (long)" {
const testing = std.testing;
const alloc = testing.allocator;