From 43dca7e2e805ba29bd5844acfb3ecef563c01da8 Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Wed, 14 Jan 2026 21:39:06 +0100 Subject: [PATCH] refactor: add file_browser alternate select mode --- src/keybind/builtin/flow.json | 1 + src/tui/mode/mini/file_browser.zig | 13 +++++++++++++ 2 files changed, 14 insertions(+) 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); }