fix(grep): stream ripgrep output to prevent memory exhaustion
rg runs on some really common string on some large search space e.g. cd / && rg /
it waits for ALL the results to finish...
It used to load all the results (imagine 1 GB of text) all into memory.
Then string split, (allocating another 1+ GB of memory).
It would also do stat calls for all results
Then finally only fetch the first 100.
Now when you do sinful rg it returns instantly and saves your memory/disk for better things.
Note: There would be a behavior regression here - it used to load all results and when truncating to 100 it is sorted by recently modified We could do a hybrid approach here - allow streaming in 2000(?) results and return the most recent 100 out of that (killing rg) to limit worst case, but still provide a good experience for small search results.