nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 44d38815cc9f3ae16218530897b61ada24cb6414
parent b23a5d5b291081b150337a4306dabee585cf8423
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Fri, 28 Jun 2019 20:07:42 +0200

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.

Diffstat:
Msrc/global.c | 3+++
Msrc/proto.h | 2++
Msrc/winio.c | 7++++++-
3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/global.c b/src/global.c @@ -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. */ diff --git a/src/proto.h b/src/proto.h @@ -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; diff --git a/src/winio.c b/src/winio.c @@ -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