tweaks: adjust two comments, and reshuffle two fragments

Also rename two variables, to be more fitting.
master
Benno Schulenberg 2021-04-21 16:51:33 +02:00
parent 49d8b99e4f
commit 2cdff6c32c
4 changed files with 14 additions and 20 deletions

View File

@ -49,12 +49,9 @@ void do_deletion(undo_type action)
&openfile->current->data[openfile->current_x + charlen], &openfile->current->data[openfile->current_x + charlen],
line_len - charlen + 1); line_len - charlen + 1);
#ifndef NANO_TINY #ifndef NANO_TINY
/* When softwrapping, recompute the number of chunks in the line, /* When softwrapping, a changed number of chunks requires a refresh. */
* and schedule a refresh if the number changed. */ if (ISSET(SOFTWRAP) && extra_chunks_in(openfile->current) != old_amount)
if (ISSET(SOFTWRAP)) {
if (extra_chunks_in(openfile->current) != old_amount)
refresh_needed = TRUE; refresh_needed = TRUE;
}
/* Adjust the mark if it is after the cursor on the current line. */ /* Adjust the mark if it is after the cursor on the current line. */
if (openfile->mark == openfile->current && if (openfile->mark == openfile->current &&

View File

@ -544,9 +544,8 @@ void redecorate_after_switch(void)
} }
#ifndef NANO_TINY #ifndef NANO_TINY
/* While in a different buffer, the effective width of the screen may /* While in a different buffer, the width of the screen may have changed,
* have changed, so make sure that * so make sure that the starting column for the first row is fitting. */
* the starting column for the first row get corresponding values. */
ensure_firstcolumn_is_aligned(); ensure_firstcolumn_is_aligned();
#endif #endif

View File

@ -1468,14 +1468,12 @@ void inject(char *burst, size_t count)
/* When softwrapping and the number of chunks in the current line changed, /* 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, * or we were on the last row of the edit window and moved to a new chunk,
* we need a full refresh. */ * we need a full refresh. */
if (ISSET(SOFTWRAP)) { if (ISSET(SOFTWRAP) && (extra_chunks_in(openfile->current) != old_amount ||
if (extra_chunks_in(openfile->current) != old_amount ||
(openfile->current_y == editwinrows - 1 && (openfile->current_y == editwinrows - 1 &&
chunk_for(xplustabs(), openfile->current) > original_row)) { chunk_for(xplustabs(), openfile->current) > original_row))) {
refresh_needed = TRUE; refresh_needed = TRUE;
focusing = FALSE; focusing = FALSE;
} }
}
#endif #endif
openfile->placewewant = xplustabs(); openfile->placewewant = xplustabs();

View File

@ -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. */ /* Draw a scroll bar on the righthand side of the screen. */
void draw_scrollbar(void) void draw_scrollbar(void)
{ {
int totalrows = openfile->filebot->lineno; int totallines = openfile->filebot->lineno;
int first_row = openfile->edittop->lineno; int fromline = openfile->edittop->lineno - 1;
int lowest = ((first_row - 1) * editwinrows) / totalrows; int lowest = (fromline * editwinrows) / totallines;
int highest = lowest + (editwinrows * editwinrows) / totalrows; int highest = lowest + (editwinrows * editwinrows) / totallines;
if (editwinrows > totalrows) if (editwinrows > totallines)
highest = editwinrows; highest = editwinrows;
for (int row = 0; row < editwinrows; row++) { for (int row = 0; row < editwinrows; row++) {