Control: tags -1 patch On 2020-11-17 03:03:03 +0100, Vincent Lefevre wrote: > On 2020-11-17 02:07:08 +0100, Vincent Lefevre wrote: > > 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). > > Actually this is not that simple. There is a confusion between > logical lines and physical lines, so that this patch does not > work well when the file starts with long lines (longer than the > width of the terminal).
I've updated my patch to avoid this issue. But now the spurious empty lines before the beginning of the file are avoided only when going to the beginning of the file, more precisely to the special line 0, like with 'g' or '<' (without a line number first). This is done by ignoring jump_sline (the value of the -j option) in this case; jump_sline is still honored when going to any positive line number, so that empty lines may still appear in this case (like in searches). -- 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 Ignore jump_sline (-j value) when going to the beginning of the file, i.e. avoid empty lines that would otherwise appear before. Note that jump_sline is still honored when going to a positive line number, so that empty lines may appear in this case (like in searches). Author: Vincent Lefevre <vinc...@vinc17.net> Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=763631 Last-Update: 2020-11-17 diff --git a/command.c b/command.c index 9b71377..b4b9cce 100644 --- a/command.c +++ b/command.c @@ -1109,6 +1109,7 @@ commands(VOID_PARAM) int action; char *cbuf; int newaction; + int save_jump_sline; int save_search_type; char *extra; char tbuf[2]; @@ -1410,11 +1411,18 @@ commands(VOID_PARAM) case A_GOLINE: /* * Go to line N, default beginning of file. + * If N <= 0, ignore jump_sline in order to avoid + * empty lines before the beginning of the file. */ + save_jump_sline = jump_sline; if (number <= 0) + { number = 1; + jump_sline = 0; + } cmd_exec(); jump_back(number); + jump_sline = save_jump_sline; break; case A_PERCENT: