less icon indicating copy to clipboard operation
less copied to clipboard

fix: don't twiddle null lines during `quit_if_one_screen` render

Open turbocrime opened this issue 6 months ago • 5 comments

don't output tildes or blank lines if not paging a single-screen output

fixes https://github.com/gwsw/less/issues/624

test cases:

seq 5 | less -F +G
echo "single line" | less -F +G --tilde

turbocrime avatar May 16 '25 19:05 turbocrime

Can you give an example where less displays tildes or blank lines on a single screen output? For example, there are no such lines if I do seq 5 | less -F.

gwsw avatar May 16 '25 19:05 gwsw

Can you give an example where less displays tildes or blank lines on a single screen output? For example, there are no such lines if I do seq 5 | less -F.

sorry for low detail. filed an issue after making the pr... examples are here: https://github.com/gwsw/less/issues/624

the issue is present when combined with +G like less -F +G

uncertain but this may also be relevant to https://github.com/gwsw/less/issues/28

turbocrime avatar May 16 '25 19:05 turbocrime

i tried to make a test for this using lesstest, but the generated test didn't seem to notice a difference in output. does it totally ignore null lines?

turbocrime avatar May 16 '25 20:05 turbocrime

it seems like using the condition with one_screen resulted in correct behavior of the pipe example, but was not successful at correcting the git pager behavior. i don't understand why that would be the case.

removing one_screen and just using quit_if_one_screen seems to produce correct behavior in both cases, and as far as i can tell doesn't result in an overeager suppression, because quit_if_one_screen is set to 'false' after the first render

https://github.com/gwsw/less/blob/6d1fcd3a35dd3467cd7266ca907e04d36cf36df2/command.c#L879-L886

turbocrime avatar May 16 '25 21:05 turbocrime

okay, maybe not entirely fixes #28

the initial git diff pager example is improved - when paging, the 'pattern' option still highlights the matches, and sets up the 'next' key command. when content fits the screen, it correctly skips paging mode, without filling the screen. this could be considered 'the issue', and it is corrected by this PR.

but comments describe this case which is arguably degraded:

seq 10 | less --quit-if-one-screen +/8

it still (incorrectly?) enters paging mode, but the experience is worse because existing screen content is not cleared by the null-lines twiddle.

turbocrime avatar May 17 '25 06:05 turbocrime

Fixed by addition of the --cmd option in 3979f5cb7f12480ee676311921c8d097973d9e4e.

gwsw avatar Aug 10 '25 17:08 gwsw