display: clear the remainder of a row only when there actually is some

Make display_string() report back (via a global variable) whether the
just converted string has room to spare within the allotted span, so
that draw_row() can avoid trying to clear the remainder when there is
nothing to clear.

This fixes https://savannah.gnu.org/bugs/?56562.

Bug existed since commit 699cacf7 from three days ago.
This commit is contained in:
Benno Schulenberg 2019-06-28 20:07:42 +02:00
parent b23a5d5b29
commit 44d38815cc
3 changed files with 11 additions and 1 deletions

View File

@ -68,6 +68,9 @@ bool more_than_one = FALSE;
bool also_the_last = FALSE;
/* Whether indenting/commenting should include the last line of
* the marked region. */
bool is_shorter;
/* Whether a row's text is narrower than the screen's width. */
int didfind = 0;
/* Whether the last search found something. */

View File

@ -55,6 +55,8 @@ extern bool more_than_one;
extern bool also_the_last;
extern bool is_shorter;
extern int didfind;
extern int controlleft, controlright;

View File

@ -2023,6 +2023,8 @@ char *display_string(const char *buf, size_t column, size_t span,
#endif
}
is_shorter = (column < beyond);
/* Null-terminate the converted string. */
converted[index] = '\0';
@ -2440,7 +2442,10 @@ void draw_row(int row, const char *converted, linestruct *line, size_t from_col)
/* First simply write the converted line -- afterward we'll add colors
* and the marking highlight on just the pieces that need it. */
mvwaddstr(edit, row, margin, converted);
wclrtoeol(edit);
/* When needed, clear the remainder of the row. */
if (is_shorter || ISSET(SOFTWRAP))
wclrtoeol(edit);
#ifdef USING_OLD_NCURSES
/* Tell ncurses to really redraw the line without trying to optimize