wrapping: make relative fill values work again also for screen resizes

The 'wrap_at' variable, removed in commit e90b7cf4, is actually needed
to store the original value of the --fill option when it is negative.
Otherwise, changing the screen width will not update the wrapping point
properly.

This fixes https://savannah.gnu.org/bugs/?54861.
Reported-by: Brand Huntsman <alpha@qzx.com>
master
David Lawrence Ramsey 2018-10-17 18:01:01 -05:00 committed by Benno Schulenberg
parent 769a0e661f
commit 16a3dc90c7
4 changed files with 9 additions and 6 deletions

View File

@ -80,8 +80,10 @@ int shiftaltleft, shiftaltright, shiftaltup, shiftaltdown;
#endif
#ifdef ENABLED_WRAPORJUSTIFY
ssize_t fill = -COLUMNS_FROM_EOL;
/* The column where we will wrap lines. */
ssize_t wrap_at = -COLUMNS_FROM_EOL;
/* The relative column where we will wrap lines. */
ssize_t fill = 0;
/* The actual column where we will wrap lines, based on wrap_at. */
#endif
char *last_search = NULL;

View File

@ -721,6 +721,7 @@ void window_init(void)
#ifdef ENABLED_WRAPORJUSTIFY
/* Set up the wrapping point, accounting for screen width when negative. */
fill = wrap_at;
if (fill <= 0)
fill += COLS;
if (fill < 0)
@ -2242,7 +2243,7 @@ int main(int argc, char **argv)
#endif
#ifdef ENABLED_WRAPORJUSTIFY
case 'r':
if (!parse_num(optarg, &fill)) {
if (!parse_num(optarg, &wrap_at)) {
fprintf(stderr, _("Requested fill size \"%s\" is invalid"), optarg);
fprintf(stderr, "\n");
exit(1);

View File

@ -72,7 +72,7 @@ extern int shiftaltup, shiftaltdown;
#endif
#ifdef ENABLED_WRAPORJUSTIFY
extern ssize_t fill;
extern ssize_t wrap_at, fill;
#endif
extern char *last_search;

View File

@ -1104,10 +1104,10 @@ void parse_rcfile(FILE *rcstream, bool syntax_only)
#endif
#ifdef ENABLED_WRAPORJUSTIFY
if (strcasecmp(rcopts[i].name, "fill") == 0) {
if (!parse_num(option, &fill)) {
if (!parse_num(option, &wrap_at)) {
rcfile_error(N_("Requested fill size \"%s\" is invalid"),
option);
fill = -COLUMNS_FROM_EOL;
wrap_at = -COLUMNS_FROM_EOL;
} else
UNSET(NO_WRAP);
free(option);