less: correctly account for tabs when rewrapping lines

Lines are rewrapped when the terminal width changes or line numbers
are enabled/disabled.  The current calculation always adds eight to
the line length for a tab whereas it should only add enough to move
to the next tab stop.

This doesn't affect the display of lines, which is handled elsewhere
and gets tab stops right, but it does cause lines to be wrapped at
the wrong position.

Signed-off-by:  Ron Yorston <rmy@frippery.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Ron Yorston authored and Denys Vlasenko committed 2015-07-19 22:50:25 +02:00
1 parent f06386ad4f
commit 78cfa00154
1 file changed
+3 -1
+3 -1
View File
@@ -331,8 +331,10 @@ static void re_wrap(void)
*d = *s;
if (*d != '\0') {
new_line_pos++;
if (*d == '\t') /* tab */
if (*d == '\t') { /* tab */
new_line_pos += 7;
new_line_pos &= (~7);
}
s++;
d++;
if (new_line_pos >= w) {