To reproduce: perl -e 'print "\n", "junk" x 1000, "goodness"' |less +/goodness The result is that the first line on the screen is the beginning of the long 'junk' line, and 'goodness' (the target of the search) is well past the bottom of the displayed screen. This makes the search function effectively useless in files with many very long lines, since the user must then visually scan a large number of screens of text in order to find the actual match. less should arrange for this line to be immediately visible when the search succeeds. I have confirmed that this bug also exists in less 374, but not in 358.
----- Forwarded message from Matt Zimmerman <mdz@debian.org> ----- Subject: Bug#153576: Search is broken on very long lines Reply-To: "Matt Zimmerman" <mdz@debian.org>, 153576@bugs.debian.org From: "Matt Zimmerman" <mdz@debian.org> To: "Debian Bug Tracking System" <submit@bugs.debian.org> Date: Fri, 19 Jul 2002 10:56:52 -0400 Sender: Matt Zimmerman <mdz@poseidon> Package: less Version: 376-2 Severity: normal To reproduce: perl -e 'print "\n", "junk" x 1000, "goodness"' |less +/goodness The result is that the first line on the screen is the beginning of the long 'junk' line, and 'goodness' (the target of the search) is well past the bottom of the displayed screen. This makes the search function effectively useless in files with many very long lines, since the user must then visually scan a large number of screens of text in order to find the actual match. less should arrange for this line to be immediately visible when the search succeeds. I have confirmed that this bug also exists in less 374, but not in 358.----- End forwarded message -----
I've looked into this a little further, and the problem seems to be related to the dynamic expansion of linebuf. After much trial and error, I found that the problem only occurs if the buffer is expanded during forw_raw_line. Disabling the expand_linebuf() call in that function, and acting as if it failed (reverting to the 358 behaviour), causes (this particular manifestation of) the problem to vanish. In fact, it's starting to look as if this was an accidental feature. The highlighted pattern match would always be on the screen because it was broken up into 1024-character lines, which (for text data) will always fit on an 80x25 terminal. So I guess this becomes a feature request, "please make sure that the match is on the screen after a search".