Compare commits
2 commits
bfefe2f99d
...
65f65842a2
| Author | SHA1 | Date | |
|---|---|---|---|
| 65f65842a2 | |||
| 43dca7e2e8 |
3 changed files with 19 additions and 1 deletions
|
|
@ -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"]
|
||||
]
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 {};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue