From 2cdff6c32ca80f623cd39f79cf6bbe1281dc58a3 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Wed, 21 Apr 2021 16:51:33 +0200 Subject: [PATCH] tweaks: adjust two comments, and reshuffle two fragments Also rename two variables, to be more fitting. --- src/cut.c | 9 +++------ src/files.c | 5 ++--- src/nano.c | 10 ++++------ src/winio.c | 10 +++++----- 4 files changed, 14 insertions(+), 20 deletions(-) diff --git a/src/cut.c b/src/cut.c index a51f2156..9079ce97 100644 --- a/src/cut.c +++ b/src/cut.c @@ -49,12 +49,9 @@ void do_deletion(undo_type action) &openfile->current->data[openfile->current_x + charlen], line_len - charlen + 1); #ifndef NANO_TINY - /* When softwrapping, recompute the number of chunks in the line, - * and schedule a refresh if the number changed. */ - if (ISSET(SOFTWRAP)) { - if (extra_chunks_in(openfile->current) != old_amount) - refresh_needed = TRUE; - } + /* When softwrapping, a changed number of chunks requires a refresh. */ + if (ISSET(SOFTWRAP) && extra_chunks_in(openfile->current) != old_amount) + refresh_needed = TRUE; /* Adjust the mark if it is after the cursor on the current line. */ if (openfile->mark == openfile->current && diff --git a/src/files.c b/src/files.c index 0ddd03cf..8bc1a828 100644 --- a/src/files.c +++ b/src/files.c @@ -544,9 +544,8 @@ void redecorate_after_switch(void) } #ifndef NANO_TINY - /* While in a different buffer, the effective width of the screen may - * have changed, so make sure that - * the starting column for the first row get corresponding values. */ + /* While in a different buffer, the width of the screen may have changed, + * so make sure that the starting column for the first row is fitting. */ ensure_firstcolumn_is_aligned(); #endif diff --git a/src/nano.c b/src/nano.c index 92319dc6..1011148f 100644 --- a/src/nano.c +++ b/src/nano.c @@ -1468,13 +1468,11 @@ void inject(char *burst, size_t count) /* When softwrapping and the number of chunks in the current line changed, * or we were on the last row of the edit window and moved to a new chunk, * we need a full refresh. */ - if (ISSET(SOFTWRAP)) { - if (extra_chunks_in(openfile->current) != old_amount || + if (ISSET(SOFTWRAP) && (extra_chunks_in(openfile->current) != old_amount || (openfile->current_y == editwinrows - 1 && - chunk_for(xplustabs(), openfile->current) > original_row)) { - refresh_needed = TRUE; - focusing = FALSE; - } + chunk_for(xplustabs(), openfile->current) > original_row))) { + refresh_needed = TRUE; + focusing = FALSE; } #endif diff --git a/src/winio.c b/src/winio.c index e4b4867a..438b0baa 100644 --- a/src/winio.c +++ b/src/winio.c @@ -3055,12 +3055,12 @@ bool less_than_a_screenful(size_t was_lineno, size_t was_leftedge) /* Draw a scroll bar on the righthand side of the screen. */ void draw_scrollbar(void) { - int totalrows = openfile->filebot->lineno; - int first_row = openfile->edittop->lineno; - int lowest = ((first_row - 1) * editwinrows) / totalrows; - int highest = lowest + (editwinrows * editwinrows) / totalrows; + int totallines = openfile->filebot->lineno; + int fromline = openfile->edittop->lineno - 1; + int lowest = (fromline * editwinrows) / totallines; + int highest = lowest + (editwinrows * editwinrows) / totallines; - if (editwinrows > totalrows) + if (editwinrows > totallines) highest = editwinrows; for (int row = 0; row < editwinrows; row++) {