Skip to content
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

Confused about flag --print-long-lines: long lines seem to be printed by default? But can't turn that behavior *off* or modify it? (like --print-long-lines=false or --print-long-lines=200 or something?) #1524

Open
dwawlyn opened this issue Jul 16, 2023 · 0 comments

Comments

@dwawlyn
Copy link

dwawlyn commented Jul 16, 2023

Hi, I'm confused about the flag --print-long-lines.
Unless I'm misunderstanding something more fundamental about how you're supposed to use it,
it seems broken to me?

The manpage/help just says:
--print-long-lines Print matches on very long lines (Default: >2k characters)

But for me, long lines are printed by default,
and I can't find any way to turn that behavior off (or adjust it),
trying things like:

  • --print-long-lines false
  • --print-long-lines=false
  • --print-long-lines=no
  • --print-long-lines 100
  • --print-long-lines=100

(I made sure I didn't accidentally have ag wrapped in an alias that already included the flag or something ; my ag is indeed just plain /usr/bin/ag.)


Like, I just set up a test like this [(looks weird cuz fishshell)]:
$

for n in 2 20 200 2000 2200
	echo "$(string repeat -n (math "$n-1") "_")x" > file_$n.txt
end

(
such that
$

cat *

#=>

_x
___________________x
_______________________________________________________________________________________________________________________________________________________________________________________________________x
_______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________x
_______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________x

)

and then both
$

ag x

and
$

ag x --print-long-lines

get exactly the same result
#=>

file_2.txt
1:_x

file_20.txt
1:___________________x

file_200.txt
1:_______________________________________________________________________________________________________________________________________________________________________________________________________x

file_2000.txt
1:_______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________x

file_2200.txt
1:_______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________x

[
I actually passed that through pty and aha to try to keep the formatting/colors the same as you actually see when using it interactively
like:
$

pty ag x|aha -n -b

and then tried putting the output of that in <pre></pre> tags,
but of course that doesn't actually display the colors here...

I'm not sure how to get the colors to actually show up in a github comment,
if that's even possible(?),
but yeah,
the above block is actually underlyingly:

<pre>
<span style="font-weight:bold;color:lime;">file_2.txt</span>
<span style="font-weight:bold;color:yellow;">1</span>:_<span style="color:dimgray;background-color:yellow;">x</span>

<span style="font-weight:bold;color:lime;">file_20.txt</span>
<span style="font-weight:bold;color:yellow;">1</span>:___________________<span style="color:dimgray;background-color:yellow;">x</span>

<span style="font-weight:bold;color:lime;">file_200.txt</span>
<span style="font-weight:bold;color:yellow;">1</span>:_______________________________________________________________________________________________________________________________________________________________________________________________________<span style="color:dimgray;background-color:yellow;">x</span>

<span style="font-weight:bold;color:lime;">file_2000.txt</span>
<span style="font-weight:bold;color:yellow;">1</span>:_______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________<span style="color:dimgray;background-color:yellow;">x</span>

<span style="font-weight:bold;color:lime;">file_2200.txt</span>
<span style="font-weight:bold;color:yellow;">1</span>:_______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________<span style="color:dimgray;background-color:yellow;">x</span>
</pre>

]


Actually, now that I'm thinking about it,
maybe a feature request:
expand the "before/after/context" flags so they can also take number of characters before/after?
(Right now, they only take lines.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant