fix: limit ripgrep processing to 1000 lines of output
More is not really useful and potentially very laggy.
This commit is contained in:
parent
3b4687761e
commit
cf2b9c76ed
1 changed files with 8 additions and 1 deletions
|
@ -161,16 +161,23 @@ const Process = struct {
|
||||||
|
|
||||||
fn handle_terminated(self: *Process) !void {
|
fn handle_terminated(self: *Process) !void {
|
||||||
const output = try self.output.toOwnedSlice();
|
const output = try self.output.toOwnedSlice();
|
||||||
|
var count: usize = 0;
|
||||||
var it = std.mem.splitScalar(u8, output, '\n');
|
var it = std.mem.splitScalar(u8, output, '\n');
|
||||||
while (it.next()) |json| {
|
while (it.next()) |json| {
|
||||||
if (json.len == 0) continue;
|
if (json.len == 0) continue;
|
||||||
var msg_buf: [tp.max_message_size]u8 = undefined;
|
var msg_buf: [tp.max_message_size]u8 = undefined;
|
||||||
const msg: tp.message = .{ .buf = try cbor.fromJson(json, &msg_buf) };
|
const msg: tp.message = .{ .buf = try cbor.fromJson(json, &msg_buf) };
|
||||||
try self.dispatch(msg);
|
try self.dispatch(msg);
|
||||||
|
count += 1;
|
||||||
|
if (count > 1000) break;
|
||||||
}
|
}
|
||||||
try self.parent.send(.{ self.tag, "done" });
|
try self.parent.send(.{ self.tag, "done" });
|
||||||
|
if (count > 1000) {
|
||||||
|
self.logger.print("found more than {d} matches", .{self.match_count});
|
||||||
|
} else {
|
||||||
self.logger.print("found {d} matches", .{self.match_count});
|
self.logger.print("found {d} matches", .{self.match_count});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn dispatch(self: *Process, m: tp.message) !void {
|
fn dispatch(self: *Process, m: tp.message) !void {
|
||||||
var obj = std.json.ObjectMap.init(self.allocator);
|
var obj = std.json.ObjectMap.init(self.allocator);
|
||||||
|
|
Loading…
Add table
Reference in a new issue