Skip to content

Commit

Permalink
Fix --shift and --match-shift on command line with fractional parameter.
Browse files Browse the repository at this point in the history
Setting --shift calls calc_shift_count() and setting --match-shift calls
calc_match_shift(). When the parameter begins with a '.', these calculate
the value as a fraction of the screen width. But at startup when these
functions are called from scan_option(), the screen width is not yet known.
So call them in get_term() after the screen width is first determined.
Previously this was done for calc_jump_sline() but it also needs to be
done for the other two.
  • Loading branch information
gwsw committed Aug 5, 2024
1 parent e6ba382 commit 5701f02
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
3 changes: 3 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@

* Fix bug when using #stop in a lesskey file (github #551).

* Fix bug when using --shift or --match-shift on command line with
a parameter starting with '.' (github #553).

======================================================================

Major changes between "less" versions 643 and 661
Expand Down
10 changes: 10 additions & 0 deletions screen.c
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,17 @@ static void scrsize(void)
}
if (sc_width <= 0)
sc_width = DEF_SC_WIDTH;
screen_size_changed();
}

/*
* Recalculate things that depend on the screen size.
*/
public void screen_size_changed(void)
{
calc_jump_sline();
calc_shift_count();
calc_match_shift();
}

#if MSDOS_COMPILER==MSOFTC
Expand Down
4 changes: 1 addition & 3 deletions signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,7 @@ public void psignals(void)
if (sc_width != old_width || sc_height != old_height)
{
wscroll = (sc_height + 1) / 2;
calc_jump_sline();
calc_shift_count();
calc_match_shift();
screen_size_changed();
}
screen_trashed();
}
Expand Down
3 changes: 2 additions & 1 deletion version.c
Original file line number Diff line number Diff line change
Expand Up @@ -1023,7 +1023,8 @@ v659 6/20/24 Fix typo in help.
v660 6/24/24 Fix bug in ixerror.
v661 6/29/24 Simpler fix for ixerror bug.
v662 Fix build with --with-secure; improve true colors on Windows;
fix crash with --header; fix crash with -S.
fix crash with --header; fix crash with -S; fix #stop;
fix --shift with fractional parameter.
*/

char version[] = "662x";

0 comments on commit 5701f02

Please sign in to comment.