From d07389b8ee12edba4c29ef3147ca917d645cabca Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Sun, 1 Feb 2026 20:00:01 +0100 Subject: [PATCH 1/2] fix: wrong prefix for single line reflows --- src/buffer/reflow.zig | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/buffer/reflow.zig b/src/buffer/reflow.zig index b191a06..3f8fe39 100644 --- a/src/buffer/reflow.zig +++ b/src/buffer/reflow.zig @@ -60,8 +60,16 @@ fn detect_prefix(text: []const u8) Prefix { var lines = std.mem.splitScalar(u8, text, '\n'); const line1 = lines.next() orelse return .{}; var prefix: []const u8 = line1; - while (lines.next()) |line| + var count: usize = 0; + while (lines.next()) |line| { prefix = lcp(prefix, line); + count += 1; + } + if (count < 1) return .{ + .len = 0, + .first = &.{}, + .continuation = &.{}, + }; if (line1.len > prefix.len + 2 and line1[prefix.len] == '-' and line1[prefix.len + 1] == ' ') { const first = line1[0 .. prefix.len + 2]; From a3ea183ba1a163eb58979cdeb0d924ab8aaf40c4 Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Sun, 1 Feb 2026 20:14:16 +0100 Subject: [PATCH 2/2] fix: completion dropdown must dupe completion data Because it might be erased by the next completion response. closes #477 --- src/tui/mode/overlay/completion_dropdown.zig | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/tui/mode/overlay/completion_dropdown.zig b/src/tui/mode/overlay/completion_dropdown.zig index 5708532..7c9592a 100644 --- a/src/tui/mode/overlay/completion_dropdown.zig +++ b/src/tui/mode/overlay/completion_dropdown.zig @@ -36,6 +36,7 @@ pub const ValueType = struct { query: ?Buffer.Selection = null, last_query: ?[]const u8 = null, commands: command.Collection(cmds) = undefined, + data: []const u8 = &.{}, }; pub const defaultValue: ValueType = .{}; @@ -53,7 +54,9 @@ pub fn load_entries(self: *Type) !usize { self.value.cursor = self.value.editor.get_primary().cursor; self.value.query = null; - var iter: []const u8 = self.value.editor.completions.data.items; + self.allocator.free(self.value.data); + self.value.data = try self.allocator.dupe(u8, self.value.editor.completions.data.items); + var iter: []const u8 = self.value.data; while (iter.len > 0) { var cbor_item: []const u8 = undefined; if (!try cbor.matchValue(&iter, cbor.extract_cbor(&cbor_item))) return error.BadCompletion; @@ -90,6 +93,7 @@ pub fn load_entries(self: *Type) !usize { } pub fn deinit(self: *Type) void { + self.allocator.free(self.value.data); if (self.value.last_query) |p| self.allocator.free(p); self.value.commands.deinit(); }