-
Notifications
You must be signed in to change notification settings - Fork 84
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
Bug when chopping long lines when using -r #127
Comments
This is intentional, because when -r is enabled, escape sequences are sent directly to the terminal. In that case less has no way to know where to wrap lines. An escape sequence might move the cursor arbitrarily any number of spaces to the right or left, or even up/down. In general -r should only be used in extremely limited situations, when you know the contents of the file contain escape sequences that you are willing to send to the terminal and are willing to give up less keeping track of line lengths. Is there a specific reason you are using -r? This is noted in the man page:
|
I use -r to deal with colored output. It would have been awesome if less recognized at least some standard ANSI escape sequences (color, bold, etc.). In this day and age, "almost everyone" uses a terminal emulator and therefore "almost everyone" uses ANSI escape codes (that is, some variant of xterm). But that's a large task. Still, less wraps longs lines even when -r is used, so it does have some prediction of what's going on, even if inaccurate. Doesn't it make sense that, similarly to still wrapping long lines, it would also still allow chopping them? |
If you just want to support color, you should use -R rather than -r. |
Ugh, I should have seen -R. Seems like -R is a "new" flag, only 20 years old or so ;-) I have been using less since the 80s when it didn't have such fancy features. Goes to show that one should re-read the man pages for the utilities once every decade or so and update one's aliases accordingly. Sorry to have bothered you. My bad. |
For a long time less hasn't been working for me when there were long lines to be wrapped.
Specifically lines were disappearing - the display was flat out wrong.
I chalked it up to some weird xtrem issue.
This isn't about bad line wrapping though.
I have decided to just chop long lines and scroll to the right when the line is long.
To my surprise, -S/--chop-long-lines had no effect (long lines were still wrapped).
I downloaded the latest version. Still no chopping long lines.
Looked around in the code and came upon line 697 in line.c:
Aha! I was using the -r flag by default and this seems to be disabling -S.
It seems unreasonable to me that the -r flag should have anything whatsoever to do with the -S behavior. So I changed this line to:
And haleluja, less started chopping lines when -S was specified as expected, even when using -r.
This seems to be a bug... or am I missing something? Without this fix I just can't force less to chop long lines no matter what I do.
Environment:
Latest less version v579, commit c763f86
Terminal program: MobaXterm Personal Edition v20.5 Build 4502
TERM: xterm-color
stty -a:
The text was updated successfully, but these errors were encountered: