-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
-M should show a preview of the line if the line is too long #1078
Comments
I don't think I'm willing to change the existing behavior here. The problem I have with ag's behavior is that it makes it much less obvious that a line has been truncated. I guess this is more of a display/UX problem that could be solved as opposed to a problem with the idea itself. If we do this, it will probably have to be behind a flag, e.g., |
For whatever it might be worth, i found ripgrep's I know how much you care about BC, and i don't often run into files with stupidly long lines anyway, so i never mentioned it — but i ended up just removing I don't currently have any strong opinions on the UX/BC stuff other than that, but there's another perspective for you, in any case |
@okdana Thanks! If |
For sure, yeah |
I don't know if you want this here are or as its own separate issue, but it would be nice if ripgrep had flags analogous to I find myself often enough having to scroll for tens of seconds, searching for the match. I know there's an easy enough workaround by piping the output into I think it would be nice to have ripgrep truncate long lines by default. If, say, 500 characters before and after the match were retained, that would still make it clear that there's a lot of stuff in the line without overwhelming the output. This 500 character before and after default would, I hope, not artificially truncate long lines in normal files. If this idea has support, I'd be happy to take a stab at implementing it (although it'd be nice to be pointed in the right direction). |
@BenSandeen That sounds like a different feature than this. I'm not sure it's a good fit though. I don't think any sort of trimming/truncation will ever happen by default though. |
@okdana You mentioned that you liked how ... okay, looking at ag's source, I see why: Ah okay, looking at Working backwards from that lead me to its All right, so its behavior appears to be that it cuts off the line at the given number of bytes, and then prints a Should ripgrep do the same thing? Or should it use something more conspicuous like it does today, e.g., |
Oh, yeah. I had to go back and check too, i honestly haven't touched I personally like the If you're concerned about conspicuousness you might also consider giving it its own colour/style thing (possibly configured by default?), e.g. Just random thoughts though; i don't think i feel super strongly about it. My use case for this is preventing absurdly long lines (like minified JavaScript) from flooding my screen, so a few-dozen characters doesn't make too big a difference to me |
I like Actually doing this, I see why I did it the way I did it. It is... quite thorny to get this right with respect to coloring matches and multiline results. |
This commit adds support for showing a preview of long lines. While the default still remains as completely suppressing the entire line, this new functionality will show the first N graphemes of a matching line, including the number of matches that are suppressed. This was unfortunately a fairly invasive change to the printer that required a bit of refactoring. On the bright side, the single line and multi-line coloring are now more unified than they were before. Closes #1078
How to get long lines printed? I am getting the "[Omitted long line with 1 matches]" result. Thanks! |
You're getting that because that's what you asked for. It's not enabled by default. |
Thanks. |
when I run I get rg: memory: IO error for operation on memory: No such file or directory (os error 2) |
What version of ripgrep are you using?
ripgrep 0.10.0
-SIMD -AVX (compiled)
+SIMD +AVX (runtime)
How did you install ripgrep?
Homebrew
What operating system are you using ripgrep on?
Mac high sierra 10.13.6
Describe your question, feature request, or bug.
When I specify a line length with -M, and a line is too long, I cannot see
anything about what the line is. The silver searcher does what I believe to be
a more useful behaviour, which is show a preview of the line for the first lot
of characters. This is much more useful because I can tell whether this line is
generated JavaScript or not, especially if I specify the line length of -M to
be something higher like 100.
Please change the behaviour to be more like the silver searcher
The text was updated successfully, but these errors were encountered: