fix: prevent use-after-free error in open_file mini mode

This commit is contained in:
CJ van den Berg 2025-10-13 11:51:48 +02:00
parent 25a719382f
commit 239b7dfa82
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -34,12 +34,14 @@ pub fn name(_: *Type) []const u8 {
} }
pub fn select(self: *Type) void { pub fn select(self: *Type) void {
var buf: std.ArrayList(u8) = .empty; {
defer buf.deinit(self.allocator); var buf: std.ArrayList(u8) = .empty;
const file_path = project_manager.expand_home(self.allocator, &buf, self.file_path.items); defer buf.deinit(self.allocator);
if (root.is_directory(file_path)) const file_path = project_manager.expand_home(self.allocator, &buf, self.file_path.items);
tp.self_pid().send(.{ "cmd", "change_project", .{file_path} }) catch {} if (root.is_directory(file_path))
else if (file_path.len > 0) tp.self_pid().send(.{ "cmd", "change_project", .{file_path} }) catch {}
tp.self_pid().send(.{ "cmd", "navigate", .{ .file = file_path } }) catch {}; else if (file_path.len > 0)
tp.self_pid().send(.{ "cmd", "navigate", .{ .file = file_path } }) catch {};
}
command.executeName("exit_mini_mode", .{}) catch {}; command.executeName("exit_mini_mode", .{}) catch {};
} }