Use `ag --width`, `rg --max-columns`
Use `ag --width`, `rg --max-columns`

I've continued to dig in to:

    https://github.com/wincent/ferret/issues/43

and have some interesting findings.

Vim will not show anything longer than 4096 characters wide in the
quickfix listing, so it ends up spending a lot of time chewing through
huge amounts of output that it will never display.

    $ rg --vimgrep --no-heading test | cut -c 1-80 > /tmp/truncated
    $ rg --vimgrep --no-heading test > /tmp/raw
    $ ls -laF /tmp/raw /tmp/truncated
    -rw-r--r--  1 glh  wheel  230279138 May  2 18:45 /tmp/raw
    -rw-r--r--  1 glh  wheel      23800 May  2 18:45 /tmp/truncated
    $ gwc -mlL /tmp/truncated
      295 23800    80 /tmp/truncated
    $ rg --vimgrep --no-heading test | gwc -mlL
        295 230119584  864273

This is in a test directory with some ghastly big JSON files. Note the
difference in size in the output when truncating lines to 80 characters:
we drop from 230m down to 24k. As `gwc` shows, this is in a result
listing that is only 295 lines long, but which contains lines as long as
864k long.

I hacked things to pipe through `cut` inside Ferret and confirmed that
Vim was very responsive throughout, but noticed that `cut` itself makes
the results come back significantly slower:

- With `cut -c 1-80`: 9.45s
- Without `cut`: 0.14s.
- With `cut -b 1-80`: 7.38s

So that's unfortunate. At least in the case of `ag`, it has a built-in
`--width` switch that we can use to do this without the overhead of
`cut`. `rg` has an (arguably slightly less-nice) `--max-columns` switch
which instead of truncating lines replaces them with a message like
this:

> actors.json:1:650088:[Omitted long line with 266 matches]

I personally prefer the `ag` approach, but this is still good as it
largely mitigates our pain.

wincent/ferret