diff --git a/NEWS b/NEWS index 7130d1a2..1becc852 100644 --- a/NEWS +++ b/NEWS @@ -45,6 +45,9 @@ * Fix bug when using +:n +:p +:x or +:d on the command line (github #552). +* Fix bug with --no-number-headers when header is not at start of file + (github #566). + ====================================================================== Major changes between "less" versions 661 and 664 diff --git a/linenum.c b/linenum.c index 2258cdd4..9f13c8be 100644 --- a/linenum.c +++ b/linenum.c @@ -70,6 +70,7 @@ extern int sigs; extern int sc_height; extern int header_lines; extern int nonum_headers; +extern POSITION header_start_pos; /* * Initialize the line number structures. @@ -511,7 +512,14 @@ public void scan_eof(void) */ public LINENUM vlinenum(LINENUM linenum) { - if (nonum_headers) - linenum = (linenum < header_lines) ? 0 : linenum - header_lines; + if (nonum_headers && header_lines > 0) + { + LINENUM header_start_line = find_linenum(header_start_pos); + if (header_start_line != 0) + { + LINENUM header_end_line = header_start_line + header_lines; /* first line after header */ + linenum = (linenum < header_end_line) ? 0 : linenum - header_end_line + 1; + } + } return linenum; } diff --git a/version.c b/version.c index 20afc564..35532499 100644 --- a/version.c +++ b/version.c @@ -1030,7 +1030,9 @@ v663 8/16/24 Fix ^X bug when output is not a tty. v664 Fix Windows compile error. v659.1 Add --no-paste; add --no-edit-warn; add TAB for -- command; add LESSANSIOSCALLOW and LESSANSIOSCCCHARS; fix bug searching - near invalid UTF-8 sequence; add LESS_SHELL_LINES. + near invalid UTF-8 sequence; add LESS_SHELL_LINES; fix bug + with --no-number-headers. + */ char version[] = "659.1x";