Control: found -1 551-2 Control: tags -1 patch On 2014-10-01 16:15:52 +0200, Vincent Lefevre wrote: > When the -j option is used with a value larger than 1 (the purpose of > this option), n-1 spurious lines appear before the file when going to > line 1. For instance, type: > > printf "Line %d\n" `seq 200` | less -Mj3 > > and in "less", type < to go to the beginning of the file (line 1). > One gets: > > ~ > ~ > Line 1 > Line 2 > Line 3 > Line 4 > Line 5 > Line 6 > [...] > > Though the specification of -j says that the target (line 1) should > appear here at the third line of the terminal, giving empty context > lines is useless.
I've attached a simple patch. The idea is that the line number for the A_GOLINE command must not be smaller than the -j value, except when this value is larger than the screen height (this is probably an unexpected case, but it is correctly handled by my patch). -- Vincent Lefèvre <vinc...@vinc17.net> - Web: <https://www.vinc17.net/> 100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/> Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
Description: Avoid spurious empty lines before the beginning of the file Such lines otherwise occur with option -j<n> and using '<' to go to the beginning of the file. Author: Vincent Lefevre <vinc...@vinc17.net> Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=763631 Last-Update: 2020-11-17 --- less-551-a/command.c 2019-06-11 20:12:01 +0200 +++ less-551-b/command.c 2020-11-17 01:21:06 +0100 @@ -1418,8 +1418,8 @@ /* * Go to line N, default beginning of file. */ - if (number <= 0) - number = 1; + if (number < jump_sline) + number = jump_sline < sc_height ? jump_sline : sc_height; cmd_exec(); jump_back(number); break;