commit 2cdff6c32ca80f623cd39f79cf6bbe1281dc58a3
parent 49d8b99e4f174b40bc05f42bf7d7d6a919df302b
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Wed, 21 Apr 2021 16:51:33 +0200
tweaks: adjust two comments, and reshuffle two fragments
Also rename two variables, to be more fitting.
Diffstat:
4 files changed, 14 insertions(+), 20 deletions(-)
diff --git 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
@@ -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
@@ -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
@@ -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++) {