feat: add alternate select (open in split) to find_in_files mode
This commit is contained in:
parent
03c6e4def0
commit
5438f19015
3 changed files with 26 additions and 2 deletions
|
|
@ -513,7 +513,6 @@
|
|||
["alt+v", "system_paste"],
|
||||
["alt+n", "goto_next_file"],
|
||||
["alt+p", "goto_prev_file"],
|
||||
["shift+enter", "goto_prev_match"],
|
||||
["shift+f3", "goto_prev_match"],
|
||||
["up", "select_prev_file"],
|
||||
["down", "select_next_file"],
|
||||
|
|
@ -523,6 +522,7 @@
|
|||
["f10", "theme_next"],
|
||||
["escape", "mini_mode_cancel"],
|
||||
["enter", "mini_mode_select"],
|
||||
["shift+enter", "mini_mode_select_alternate"],
|
||||
["backspace", "mini_mode_delete_backwards"]
|
||||
]
|
||||
},
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ view_rows: usize = 0,
|
|||
view_cols: usize = 0,
|
||||
entries: std.ArrayList(Entry) = undefined,
|
||||
selected: ?usize = null,
|
||||
activate: ActivateMode = .normal,
|
||||
box: Widget.Box = .{},
|
||||
|
||||
const MenuType = Menu.Options(*Self).MenuType;
|
||||
|
|
@ -40,6 +41,11 @@ const ButtonType = MenuType.ButtonType;
|
|||
const path_column_ratio = 4;
|
||||
const widget_type: Widget.Type = .panel;
|
||||
|
||||
pub const ActivateMode = enum {
|
||||
normal,
|
||||
alternate,
|
||||
};
|
||||
|
||||
const Entry = struct {
|
||||
path: []const u8,
|
||||
begin_line: usize,
|
||||
|
|
@ -243,7 +249,12 @@ fn handle_menu_action(menu: **MenuType, button: *ButtonType, _: Widget.Pos) void
|
|||
self.update_selected();
|
||||
const entry = &self.entries.items[idx];
|
||||
|
||||
tp.self_pid().send(.{ "cmd", "navigate", .{
|
||||
const cmd_ = switch (menu.*.opts.ctx.activate) {
|
||||
.normal => "navigate",
|
||||
.alternate => "navigate_split_vertical",
|
||||
};
|
||||
|
||||
tp.self_pid().send(.{ "cmd", cmd_, .{
|
||||
.file = entry.path,
|
||||
.goto = .{
|
||||
entry.end_line + 1,
|
||||
|
|
@ -303,4 +314,11 @@ const cmds = struct {
|
|||
self.menu.activate_selected();
|
||||
}
|
||||
pub const goto_selected_file_meta: Meta = .{};
|
||||
|
||||
pub fn goto_selected_file_alternate(self: *Self, _: Ctx) Result {
|
||||
if (self.menu.selected == null) return tp.exit_error(error.NoSelectedFile, @errorReturnTrace());
|
||||
self.activate = .alternate;
|
||||
self.menu.activate_selected();
|
||||
}
|
||||
pub const goto_selected_file_alternate_meta: Meta = .{};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -112,6 +112,12 @@ const cmds = struct {
|
|||
}
|
||||
pub const mini_mode_select_meta: Meta = .{ .description = "Select" };
|
||||
|
||||
pub fn mini_mode_select_alternate(_: *Self, _: Ctx) Result {
|
||||
command.executeName("goto_selected_file_alternate", .{}) catch {};
|
||||
return command.executeName("exit_mini_mode", .{});
|
||||
}
|
||||
pub const mini_mode_select_alternate_meta: Meta = .{ .description = "Select alternate" };
|
||||
|
||||
pub fn mini_mode_insert_code_point(self: *Self, ctx: Ctx) Result {
|
||||
var egc: u32 = 0;
|
||||
if (!try ctx.args.match(.{tp.extract(&egc)}))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue