Misc bug fixes (#10349)

Just fixes for a couple bugs I happened across
This commit is contained in:
Mitchell Hashimoto
2026-01-16 14:13:59 -08:00
committed by GitHub
2 changed files with 31 additions and 5 deletions

View File

@@ -186,6 +186,15 @@ const SemanticPromptKVIterator = struct {
break :kv kv;
};
// If we have an empty item, we return an empty key and value.
//
// This allows for trailing semicolons, but also lets us parse
// (or rather, ignore) empty fields; for example `a=b;;e=f`.
if (kv.len < 1) return .{
.key = kv,
.value = kv,
};
const key = key: {
const index = std.mem.indexOfScalar(u8, kv, '=') orelse break :key kv;
kv[index] = 0;
@@ -348,6 +357,18 @@ test "OSC 133: prompt_start with special_key empty" {
try testing.expect(cmd.prompt_start.special_key == false);
}
test "OSC 133: prompt_start with trailing ;" {
const testing = std.testing;
var p: Parser = .init(null);
const input = "133;A;";
for (input) |ch| p.next(ch);
const cmd = p.end(null).?.*;
try testing.expect(cmd == .prompt_start);
}
test "OSC 133: prompt_start with click_events true" {
const testing = std.testing;

View File

@@ -398,11 +398,16 @@ pub const StreamHandler = struct {
break :tmux;
},
.exit => if (self.tmux_viewer) |viewer| {
// Free our viewer state
viewer.deinit();
self.alloc.destroy(viewer);
self.tmux_viewer = null;
.exit => {
// Free our viewer state if we have one
if (self.tmux_viewer) |viewer| {
viewer.deinit();
self.alloc.destroy(viewer);
self.tmux_viewer = null;
}
// And always break since we assert below
// that we're not handling an exit command.
break :tmux;
},