diff --git a/src/keybind/builtin/flow.json b/src/keybind/builtin/flow.json index 5e1797d..8417591 100644 --- a/src/keybind/builtin/flow.json +++ b/src/keybind/builtin/flow.json @@ -487,6 +487,7 @@ ["tab", "mini_mode_try_complete_file"], ["escape", "mini_mode_cancel"], ["enter", "mini_mode_select"], + ["shift+enter", "mini_mode_select_alternate"], ["backspace", "mini_mode_delete_backwards"] ] }, diff --git a/src/tui/mode/mini/file_browser.zig b/src/tui/mode/mini/file_browser.zig index 4b171d0..88f54ea 100644 --- a/src/tui/mode/mini/file_browser.zig +++ b/src/tui/mode/mini/file_browser.zig @@ -17,6 +17,11 @@ const MessageFilter = @import("../../MessageFilter.zig"); const max_complete_paths = 1024; +pub const SelectMode = enum { + normal, + alternate, +}; + pub fn Create(options: type) type { return struct { allocator: std.mem.Allocator, @@ -28,6 +33,7 @@ pub fn Create(options: type) type { complete_trigger_count: usize = 0, total_matches: usize = 0, matched_entry: usize = 0, + select: SelectMode = .normal, commands: Commands = undefined, const Commands = command.Collection(cmds); @@ -372,6 +378,13 @@ pub fn Create(options: type) type { } pub const mini_mode_select_meta: Meta = .{ .description = "Select" }; + pub fn mini_mode_select_alternate(self: *Self, _: Ctx) Result { + self.select = .alternate; + options.select(self); + self.update_mini_mode_text(); + } + pub const mini_mode_select_alternate_meta: Meta = .{ .description = "Select alternate" }; + pub fn mini_mode_paste(self: *Self, ctx: Ctx) Result { return mini_mode_insert_bytes(self, ctx); } diff --git a/src/tui/mode/mini/open_file.zig b/src/tui/mode/mini/open_file.zig index 7fda053..84ae5d2 100644 --- a/src/tui/mode/mini/open_file.zig +++ b/src/tui/mode/mini/open_file.zig @@ -47,10 +47,14 @@ pub fn select(self: *Type) void { var buf: std.ArrayList(u8) = .empty; defer buf.deinit(self.allocator); const file_path = project_manager.expand_home(self.allocator, &buf, self.file_path.items); + const cmd_ = switch (self.select) { + .normal => "navigate", + .alternate => "navigate_split_vertical", + }; if (root.is_directory(file_path)) tp.self_pid().send(.{ "cmd", "change_project", .{file_path} }) catch {} else if (file_path.len > 0) - tp.self_pid().send(.{ "cmd", "navigate", .{ .file = file_path } }) catch {}; + tp.self_pid().send(.{ "cmd", cmd_, .{ .file = file_path } }) catch {}; } command.executeName("exit_mini_mode", .{}) catch {}; }