Compare commits
No commits in common. "84225983b710e8bf07de4ff3e1bd115a7038e575" and "23e90b9592bfb736b626fa965325bb118b08fa12" have entirely different histories.
84225983b7
...
23e90b9592
2 changed files with 7 additions and 32 deletions
|
|
@ -32,7 +32,6 @@ enable_auto_save: bool = false,
|
|||
limit_auto_save_file_types: ?[]const []const u8 = null, // null means *all*
|
||||
enable_prefix_keyhints: bool = true,
|
||||
enable_auto_find: bool = true,
|
||||
initial_find_query: InitialFindQuery = .selection,
|
||||
ignore_filter_stderr: bool = false,
|
||||
|
||||
auto_run_time_seconds: usize = 120, //seconds
|
||||
|
|
@ -152,10 +151,3 @@ pub const KeybindMode = enum {
|
|||
normal,
|
||||
ignore_alt_text_modifiers,
|
||||
};
|
||||
|
||||
pub const InitialFindQuery = enum {
|
||||
empty,
|
||||
selection,
|
||||
last_query,
|
||||
selection_or_last_query,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -51,14 +51,10 @@ pub fn create(allocator: Allocator, ctx: command.Context) !struct { tui.Mode, tu
|
|||
var query: []const u8 = undefined;
|
||||
if (ctx.args.match(.{ cbor.extract(&self.find_mode), cbor.extract(&query) }) catch false) {
|
||||
try self.input_.appendSlice(self.allocator, query);
|
||||
} else switch (tui.config().initial_find_query) {
|
||||
.empty => {},
|
||||
.selection => try self.set_from_current_selection(editor),
|
||||
.last_query => self.find_history_prev(),
|
||||
.selection_or_last_query => {
|
||||
try self.set_from_current_selection(editor);
|
||||
if (self.input_.items.len == 0) self.find_history_prev();
|
||||
},
|
||||
} else if (editor.get_primary().selection) |sel| ret: {
|
||||
const text = editor.get_selection(sel, self.allocator) catch break :ret;
|
||||
defer self.allocator.free(text);
|
||||
try self.input_.appendSlice(self.allocator, text);
|
||||
}
|
||||
var mode = try keybind.mode("mini/find", allocator, .{
|
||||
.insert_command = "mini_mode_insert_bytes",
|
||||
|
|
@ -78,14 +74,6 @@ pub fn deinit(self: *Self) void {
|
|||
self.allocator.destroy(self);
|
||||
}
|
||||
|
||||
fn set_from_current_selection(self: *Self, editor: *ed.Editor) !void {
|
||||
if (editor.get_primary().selection) |sel| ret: {
|
||||
const text = editor.get_selection(sel, self.allocator) catch break :ret;
|
||||
defer self.allocator.free(text);
|
||||
try self.input_.appendSlice(self.allocator, text);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn receive(self: *Self, _: tp.pid_ref, m: tp.message) error{Exit}!bool {
|
||||
var text: []const u8 = undefined;
|
||||
|
||||
|
|
@ -125,7 +113,8 @@ fn flush_input(self: *Self) !void {
|
|||
.case_folded => .case_folded,
|
||||
});
|
||||
} else {
|
||||
self.reset();
|
||||
self.editor.get_primary().selection = null;
|
||||
self.editor.init_matches_update();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -138,15 +127,9 @@ fn cmd(self: *Self, name_: []const u8, ctx: command.Context) tp.result {
|
|||
return command.executeName(name_, ctx);
|
||||
}
|
||||
|
||||
fn reset(self: *Self) void {
|
||||
self.editor.get_primary().selection = null;
|
||||
fn cancel(self: *Self) void {
|
||||
self.editor.get_primary().cursor = self.start_cursor;
|
||||
self.editor.scroll_to(self.start_view.row);
|
||||
self.editor.clear_matches();
|
||||
}
|
||||
|
||||
fn cancel(self: *Self) void {
|
||||
self.reset();
|
||||
command.executeName("exit_mini_mode", .{}) catch {};
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue