diff --git a/src/global.c b/src/global.c index fd849c80..c44b3f9d 100644 --- 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 index 06f73f2f..8fb5ce8c 100644 --- 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 index b9f19b0c..bbdaffd7 100644 --- 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