feat: detect and auto open file links in selection in open_file command

This commit is contained in:
CJ van den Berg 2025-03-04 19:04:14 +01:00
parent 3a1a36f218
commit b7aa8cd6a7
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -897,6 +897,15 @@ const cmds = struct {
pub const move_to_char_meta = .{ .description = "Move cursor to matching character" };
pub fn open_file(self: *Self, ctx: Ctx) Result {
if (get_active_selection(self.allocator)) |text| {
defer self.allocator.free(text);
const link = try root.file_link.parse(text);
switch (link) {
.file => |file| if (file.exists)
return root.file_link.navigate(tp.self_pid(), &link),
else => {},
}
}
return enter_mini_mode(self, @import("mode/mini/open_file.zig"), ctx);
}
pub const open_file_meta = .{ .description = "Open file" };