diff --git a/src/terminal/osc.zig b/src/terminal/osc.zig index 6adebf430..44e4b4bb5 100644 --- a/src/terminal/osc.zig +++ b/src/terminal/osc.zig @@ -260,7 +260,12 @@ pub const Parser = struct { }, .clipboard_kind => switch (c) { - ';' => self.state = .invalid, + ';' => { + self.command.clipboard_contents.kind = 'c'; + self.state = .string; + self.temp_state = .{ .str = &self.command.clipboard_contents.data }; + self.buf_start = self.buf_idx; + }, else => { self.command.clipboard_contents.kind = c; self.state = .clipboard_kind_end; @@ -580,6 +585,20 @@ test "OSC: get/set clipboard" { try testing.expect(std.mem.eql(u8, "?", cmd.clipboard_contents.data)); } +test "OSC: get/set clipboard (optional parameter)" { + const testing = std.testing; + + var p: Parser = .{}; + + const input = "52;;?"; + for (input) |ch| p.next(ch); + + const cmd = p.end().?; + try testing.expect(cmd == .clipboard_contents); + try testing.expect(cmd.clipboard_contents.kind == 'c'); + try testing.expect(std.mem.eql(u8, "?", cmd.clipboard_contents.data)); +} + test "OSC: report pwd" { const testing = std.testing;