diff --git a/src/ripgrep.zig b/src/ripgrep.zig index ed7419d..4ab3794 100644 --- a/src/ripgrep.zig +++ b/src/ripgrep.zig @@ -80,6 +80,7 @@ const Process = struct { tag: [:0]const u8, logger: log.Logger, stdin_behavior: std.process.Child.StdIo, + match_count: usize = 0, const Receiver = tp.Receiver(*Process); @@ -150,7 +151,6 @@ const Process = struct { fn handle_output(self: *Process, bytes: []u8) !void { try self.output.appendSlice(bytes); - // self.logger.print("{s}", .{bytes}) catch {}; } fn handle_terminated(self: *Process) !void { @@ -161,11 +161,9 @@ const Process = struct { var msg_buf: [tp.max_message_size]u8 = undefined; const msg: tp.message = .{ .buf = try cbor.fromJson(json, &msg_buf) }; try self.dispatch(msg); - // var buf: [tp.max_message_size]u8 = undefined; - // self.logger.print("json: {s}", .{try msg.to_json(&buf)}) catch {}; } - // self.logger.print("done", .{}) catch {}; try self.parent.send(.{ self.tag, "done" }); + self.logger.print("found {d} matches", .{self.match_count}); } fn dispatch(self: *Process, m: tp.message) !void { @@ -232,5 +230,6 @@ const Process = struct { } else { try self.parent.send(.{ self.tag, line, begin, line, end }); } + self.match_count += 1; } }; diff --git a/src/tui/mainview.zig b/src/tui/mainview.zig index dc60d9a..adfd2f9 100644 --- a/src/tui/mainview.zig +++ b/src/tui/mainview.zig @@ -37,7 +37,6 @@ panels: ?*WidgetList = null, last_match_text: ?[]const u8 = null, location_history: location_history, file_stack: std.ArrayList([]const u8), -find_in_files_count: usize = 0, find_in_files_done: bool = false, panel_height: ?usize = null, @@ -94,12 +93,9 @@ pub fn receive(self: *Self, from_: tp.pid_ref, m: tp.message) error{Exit}!bool { var end_pos: usize = undefined; var lines: []const u8 = undefined; if (try m.match(.{ "FIF", tp.extract(&path), tp.extract(&begin_line), tp.extract(&begin_pos), tp.extract(&end_line), tp.extract(&end_pos), tp.extract(&lines) })) { - self.find_in_files_count += 1; try self.add_find_in_files_result(path, begin_line, begin_pos, end_line, end_pos, lines); return true; } else if (try m.match(.{ "FIF", "done" })) { - log.logger("find").print("found {d} matches", .{self.find_in_files_count}); - self.find_in_files_count = 0; self.find_in_files_done = true; return true; } else if (try m.match(.{"write_restore_info"})) {