feat: add find_in_files_query command
This commit is contained in:
parent
ad43cd4395
commit
4b3904d5f2
2 changed files with 12 additions and 9 deletions
|
@ -551,6 +551,17 @@ const cmds = struct {
|
|||
tui.current().rdr.request_system_clipboard();
|
||||
}
|
||||
pub const system_paste_meta = .{ .description = "Paste from system clipboard" };
|
||||
|
||||
pub fn find_in_files_query(self: *Self, ctx: Ctx) Result {
|
||||
var query: []const u8 = undefined;
|
||||
if (!try ctx.args.match(.{tp.extract(&query)})) return error.InvalidArgument;
|
||||
log.logger("find").print("finding files...", .{});
|
||||
const find_f = ripgrep.find_in_files;
|
||||
if (std.mem.indexOfScalar(u8, query, '\n')) |_| return;
|
||||
var rg = try find_f(self.allocator, query, "FIF");
|
||||
defer rg.deinit();
|
||||
}
|
||||
pub const find_in_files_query_meta = .{ .arguments = &.{.string} };
|
||||
};
|
||||
|
||||
pub fn handle_editor_event(self: *Self, _: tp.pid_ref, m: tp.message) tp.result {
|
||||
|
@ -587,14 +598,6 @@ pub fn handle_editor_event(self: *Self, _: tp.pid_ref, m: tp.message) tp.result
|
|||
}
|
||||
}
|
||||
|
||||
pub fn find_in_files(self: *Self, query: []const u8) !void {
|
||||
log.logger("find").print("finding files...", .{});
|
||||
const find_f = ripgrep.find_in_files;
|
||||
if (std.mem.indexOfScalar(u8, query, '\n')) |_| return;
|
||||
var rg = try find_f(self.allocator, query, "FIF");
|
||||
defer rg.deinit();
|
||||
}
|
||||
|
||||
pub fn location_update(self: *Self, m: tp.message) tp.result {
|
||||
var row: usize = 0;
|
||||
var col: usize = 0;
|
||||
|
|
|
@ -86,7 +86,7 @@ fn flush_input(self: *Self) !void {
|
|||
return;
|
||||
@memcpy(self.last_buf[0..self.input.len], self.input);
|
||||
self.last_input = self.last_buf[0..self.input.len];
|
||||
try self.mainview.find_in_files(self.input);
|
||||
try command.executeName("find_in_files_query", command.fmt(.{self.input}));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue