Subject: Re: Display text file using less in Cygwin terminal or xterm incorrect when lines are longer than window width
From: Brian Inglis <[email-masked]>
To: [email-masked]
Date: Sat, 7 Aug 2021 13:33:43 -0600
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>

On 2021-08-06 23:28, C Linus Hicks via Cygwin wrote:
> I have used Cygwin and CygwinX for many years and this problem has 
> persisted for many of those years, I can't remember the last time
> this worked. >
> Using vim in an xterm or terminal window displays text in a file
> properly.
> 
> The problem with less is easy to reproduce, but there are several 
> different problems:
> 
> Create a text file with the following characteristics:
> 
> 1. Several lines are longer then your terminal window is wide, even 
>    several times as wide.
> 2. The file has fewer lines then your terminal window.
> 
> In this case, when you first open the file with less, assuming all 
> the lines will fit in your window you will see the entire file in the
> bottom of your window. If you hit the 'g' key, it will jump to the
> top, but one or more lines at the top will be missing.

Works Just Fine For Me!

With files as described, and LESS/-OPEN/-CLOSE unset, running 
/usr/bin/less, the first file is displayed with the end of its bottom 
line on the bottom line of the window, just above the less status line; 
pressing Home/End displays start of top line at top, or end of bottom 
line at bottom of window, "G" displays end of bottom line at bottom of 
window; no lines or characters missing;
subsequent files in same run after :n, displayed with start of top line 
at top of window; pressing Home/End displays start of top line at top, 
or end of bottom line at bottom of window, "G" displays end of bottom 
line at bottom of window; no lines or characters missing.

With settings below, first file displayed with start of top line at top 
of window; pressing Home/End displays start of top line at top, or end 
of bottom line at bottom of window, "G" displays end of bottom line at 
bottom of window; no lines or characters missing.

> If you add more lines to the file but still with fewer lines then 
> lines in your display window, but the number of lines that should be
> displayed when wrapped is greater than your window, then you will get
> different behavior. And if your file has more lines than than the
> window, still different.
 >
> I can't find any reports or maybe I just gave up searching because 
> the hits don't address my issue, and using less on my Linux machine
> doesn't have these problems.

I get the same behaviour with no/same settings and no issues under Linux.

> Is there a setting I am missing, or is this just a bug?

As requested for problem reporting, please attach the file with the 
output from "cygcheck -hrsv" as text, if nothing below helps.

Make sure everything is up to date with no package issues: see output 
from above.

Are you running under Cygwin 64, or 32 with no rebase issues, and no 
other issues shown in /var/log/setup.log.full?

$ less --version
less 581.2 (PCRE2 regular expressions)
Copyright (C) 1984-2021  Mark Nudelman
...
$ set | egrep LESS\|TERM 
                            LESS='-c -R -M -PM?P%Pb\% %lb/%L.?p %pb\% 
%bb/%B.?f %f.?m %i/%m.?x %x.'
LESSCLOSE='/usr/local/bin/lesspipe %s %s'
LESSOPEN='| /usr/local/bin/lesspipe %s'
TERM=xterm-256color
TERM_PROGRAM=mintty
TERM_PROGRAM_VERSION=3.5.0
$ cygcheck -c less libncursesw10 libpcre2_8_0 cygwin
Cygwin Package Information
Package              Version            Status
cygwin               3.2.0-1            OK
less                 581.2-1            OK
libncursesw10        6.1-1.20190727     OK
libpcre2_8_0         10.37-1            OK
$ head /proc/version
CYGWIN_NT-10.0-19042 version 3.2.0-340.x86_64 (corinna@calimero) (gcc 
version 9.3.0 20200312 (Fedora Cygwin 9.3.0-1) (GCC) ) 2021-03-29 08:42 UTC

Debian 32 VM:

$ less --version
less 487 (GNU regular expressions)
Copyright (C) 1984-2016  Mark Nudelman
...
$ set | egrep LESS\|TERM
COLORTERM=truecolor
LESS='-c -R -M -PM?P%Pb\% %lb/%L.?p %pb\% %bb/%B.?f %f.?m %i/%m.?x %x.'
LESSCLOSE='/usr/bin/lesspipe %s %s'
LESSOPEN='| /usr/bin/lesspipe %s'
TERM=xterm-256color
$ apt list less libncursesw6 libpcre2-8-0
Listing... Done
less/stable,stable,stable,stable,stable,stable,stable,now 487-0.1+b1 
i386 [installed,automatic]
libncursesw6/stable,stable,stable,stable,stable,stable,stable,now 
6.1+20181013-2+deb10u2 i386 [installed,automatic]
libpcre2-8-0/stable,stable,stable,stable,stable,stable,stable,now 
10.32-5 i386 [installed,automatic]
$ head /proc/version
Linux version 5.4.0-0.bpo.2-686-pae ([email-masked]) 
(gcc version 8.3.0 (Debian 8.3.0-6)) #1 SMP Debian 5.4.8-1~bpo10+1 
(2020-01-07)

-- 
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

This email may be disturbing to some readers as it contains
too much technical detail. Reader discretion is advised.
[Data in binary units and prefixes, physical quantities in SI.]

-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple