feat: detect and auto open file links in selection in open_file command
This commit is contained in:
parent
3a1a36f218
commit
b7aa8cd6a7
1 changed files with 9 additions and 0 deletions
|
@ -897,6 +897,15 @@ const cmds = struct {
|
||||||
pub const move_to_char_meta = .{ .description = "Move cursor to matching character" };
|
pub const move_to_char_meta = .{ .description = "Move cursor to matching character" };
|
||||||
|
|
||||||
pub fn open_file(self: *Self, ctx: Ctx) Result {
|
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);
|
return enter_mini_mode(self, @import("mode/mini/open_file.zig"), ctx);
|
||||||
}
|
}
|
||||||
pub const open_file_meta = .{ .description = "Open file" };
|
pub const open_file_meta = .{ .description = "Open file" };
|
||||||
|
|
Loading…
Add table
Reference in a new issue