ggreer / the_silver_searcher

A code-searching tool similar to ack, but faster.
http://geoff.greer.fm/ag/
Apache License 2.0
26.18k stars 1.43k forks source link

Ignoring super long lines #696

Open andrewthad opened 9 years ago

andrewthad commented 9 years ago

One thing that often gets in my way when I'm searching for things is that I'll get matches for random json and xml files that are rendered as one line. I never want to see these, so I looked through the man page and found an interesting flag:

--print-long-lines:
     Print matches on very long lines (> 2k characters by default)

Cool. But there are two problems. The first one is a functional issue (or maybe just my ignorance) and the second is a feature request.

  1. The man page entry seems to indicates that by default this flag is off by default. But it isn't. When I run ag on my computer, it prints a match on a line with 1368810 characters. And I don't see a way to turn this flag off either. There isn't a --noprint-long-lines flag mentioned in the man page. So basically, I don't see how to actually get the actually get the line-filtering behavior that the man page indicates is possible.
  2. Can we configure what is considered a "very long line"? In my case, it's really the lines with more than 100 characters that I would like to filter out. I would like to see a flag `--long-line-length=2000' so that I could have more control over this.

Regardless, thanks for all the hard work on this awesome tool. It is enormously helpful in my workflow, and I hope that it can become even more so.

decaff commented 9 years ago

Duplicate of #189, I think.

andrewthad commented 9 years ago

It appears so. I guess since that issue has been open two years and seems unlikely to get fixed, maybe my request could instead be to remove --print-long-lines from the documentation, since it only confuses people who expect it to work.

amfarrell commented 9 years ago

@andrewthad I agree. I've submitted https://github.com/ggreer/the_silver_searcher/pull/706 to do that. I've also submitted https://github.com/ggreer/the_silver_searcher/pull/707 to fix the underlying issue.