From 9291445c64f0c5339a11a427fe853b4e08c90e5f Mon Sep 17 00:00:00 2001 From: CO <> Date: Sun, 27 Apr 2025 18:58:19 +0200 Subject: [PATCH 1/3] Single line fix for palette crashing when its items's length is exceeded. --- src/tui/mode/overlay/palette.zig | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tui/mode/overlay/palette.zig b/src/tui/mode/overlay/palette.zig index 094d164..fd981cd 100644 --- a/src/tui/mode/overlay/palette.zig +++ b/src/tui/mode/overlay/palette.zig @@ -213,6 +213,7 @@ pub fn Create(options: type) type { self.items = 0; self.menu.reset_items(); self.menu.selected = null; + self.longest = self.inputbox.text.items.len; for (self.entries.items) |entry| self.longest = @max(self.longest, entry.label.len); From df11ec3d5f2a5aa3c113a013bdaed25399bdb145 Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Tue, 29 Apr 2025 12:51:26 +0200 Subject: [PATCH 2/3] fix: re-render on branch widget update --- src/tui/status/branch.zig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/tui/status/branch.zig b/src/tui/status/branch.zig index d11b9ab..706c7b5 100644 --- a/src/tui/status/branch.zig +++ b/src/tui/status/branch.zig @@ -93,9 +93,12 @@ fn process_git(self: *Self, m: tp.message) MessageFilter.Error!bool { } fn process_status(self: *Self, m: tp.message) MessageFilter.Error!bool { + defer Widget.need_render(); + var value: []const u8 = undefined; var ahead: []const u8 = undefined; var behind: []const u8 = undefined; + if (self.done) { self.done = false; self.changed = 0; From 47aefb6f2445392e5816691287c0366f6888c1b9 Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Wed, 30 Apr 2025 09:23:30 +0200 Subject: [PATCH 3/3] refactor: cache ripgrep binary path --- src/ripgrep.zig | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/ripgrep.zig b/src/ripgrep.zig index 219c4d4..c99b625 100644 --- a/src/ripgrep.zig +++ b/src/ripgrep.zig @@ -2,8 +2,7 @@ const std = @import("std"); const tp = @import("thespian"); const cbor = @import("cbor"); const log = @import("log"); - -pub const ripgrep_binary = "rg"; +const bin_path = @import("bin_path"); pid: ?tp.pid, stdin_behavior: std.process.Child.StdIo, @@ -121,7 +120,7 @@ const Process = struct { errdefer self.deinit(); _ = tp.set_trap(true); const args = tp.message.fmt(.{ - ripgrep_binary, + get_ripgrep(), // "--line-buffered", "--fixed-strings", "--json", @@ -182,9 +181,9 @@ const Process = struct { } else if (try m.match(.{ tp.any, tp.any, "exited", 1 })) { self.logger.print("no matches found", .{}); } else if (try m.match(.{ tp.any, tp.any, "error.FileNotFound", 1 })) { - self.logger.print_err(ripgrep_binary, "'{s}' executable not found", .{ripgrep_binary}); + self.logger.print_err(get_ripgrep(), "'{s}' executable not found", .{get_ripgrep()}); } else if (try m.match(.{ tp.any, tp.any, tp.extract(&err_msg), tp.extract(&exit_code) })) { - self.logger.print_err(ripgrep_binary, "terminated {s} exitcode: {d}", .{ err_msg, exit_code }); + self.logger.print_err(get_ripgrep(), "terminated {s} exitcode: {d}", .{ err_msg, exit_code }); } } } @@ -256,3 +255,18 @@ const Process = struct { self.match_count += 1; } }; + +const rg_binary = "rg"; +const default_rg_binary = "/bin/" ++ rg_binary; + +var rg_path: ?struct { + path: ?[:0]const u8 = null, +} = null; + +pub fn get_ripgrep() []const u8 { + const allocator = std.heap.c_allocator; + if (rg_path) |p| return p.path orelse default_rg_binary; + const path = bin_path.find_binary_in_path(allocator, rg_binary) catch default_rg_binary; + rg_path = .{ .path = path }; + return path orelse default_rg_binary; +}