fix: catch more errors in file browser

This commit is contained in:
CJ van den Berg 2024-10-14 19:27:38 +02:00
parent 67f49110dc
commit b1362814db
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
5 changed files with 20 additions and 18 deletions

View file

@ -10,7 +10,7 @@ pub const Type = @import("file_browser.zig").Create(@This());
pub const create = Type.create;
pub fn load_entries(self: *Type) !void {
pub fn load_entries(self: *Type) error{ Exit, OutOfMemory }!void {
if (tui.current().mainview.dynamic_cast(mainview)) |mv_| if (mv_.get_editor()) |editor| {
if (editor.is_dirty()) return tp.exit("unsaved changes");
if (editor.file_path) |old_path|
@ -31,7 +31,7 @@ pub fn name(_: *Type) []const u8 {
}
pub fn select(self: *Type) void {
if (root.is_directory(self.file_path.items) catch false) return;
if (root.is_directory(self.file_path.items)) return;
if (self.file_path.items.len > 0)
tp.self_pid().send(.{ "cmd", "navigate", .{ .file = self.file_path.items } }) catch {};
command.executeName("exit_mini_mode", .{}) catch {};