diff --git a/src/move.c b/src/move.c index 60d43b87cae9ea542539eea90fb889b70f8dcb18..94f5b48a57b208f9e3b3fc086f33af391a01470a 100644 --- a/src/move.c +++ b/src/move.c @@ -369,7 +369,7 @@ void do_home(void) openfile->placewewant = xplustabs(); - if (need_horizontal_scroll(was_column, openfile->placewewant)) + if (line_needs_update(was_column, openfile->placewewant)) update_line(openfile->current, openfile->current_x); } @@ -381,7 +381,7 @@ void do_end(void) openfile->current_x = strlen(openfile->current->data); openfile->placewewant = xplustabs(); - if (need_horizontal_scroll(was_column, openfile->placewewant)) + if (line_needs_update(was_column, openfile->placewewant)) update_line(openfile->current, openfile->current_x); ensure_line_is_visible(); @@ -414,10 +414,10 @@ void do_up(bool scroll_only) /* If the lines weren't already redrawn, see if they need to be. */ if (openfile->current_y > 0) { /* Redraw the prior line if it was horizontally scrolled. */ - if (need_horizontal_scroll(was_column, 0)) + if (line_needs_update(was_column, 0)) update_line(openfile->current->next, 0); /* Redraw the current line if it needs to be horizontally scrolled. */ - if (need_horizontal_scroll(0, xplustabs())) + if (line_needs_update(0, xplustabs())) update_line(openfile->current, openfile->current_x); } } @@ -492,10 +492,10 @@ void do_down(bool scroll_only) /* If the lines weren't already redrawn, see if they need to be. */ if (openfile->current_y < editwinrows - 1) { /* Redraw the prior line if it was horizontally scrolled. */ - if (need_horizontal_scroll(was_column, 0)) + if (line_needs_update(was_column, 0)) update_line(openfile->current->prev, 0); /* Redraw the current line if it needs to be horizontally scrolled. */ - if (need_horizontal_scroll(0, xplustabs())) + if (line_needs_update(0, xplustabs())) update_line(openfile->current, openfile->current_x); } } @@ -535,7 +535,7 @@ void do_left(void) openfile->placewewant = xplustabs(); - if (need_horizontal_scroll(was_column, openfile->placewewant)) + if (line_needs_update(was_column, openfile->placewewant)) update_line(openfile->current, openfile->current_x); } @@ -557,7 +557,7 @@ void do_right(void) openfile->placewewant = xplustabs(); - if (need_horizontal_scroll(was_column, openfile->placewewant)) + if (line_needs_update(was_column, openfile->placewewant)) update_line(openfile->current, openfile->current_x); if (openfile->current_x == 0) diff --git a/src/proto.h b/src/proto.h index 1415af73a5f973fe57cc8dbe2868fb6b6694db00..776b3b20abe2674acacafb060dc972f2ecb7724b 100644 --- a/src/proto.h +++ b/src/proto.h @@ -706,7 +706,7 @@ void reset_cursor(void); void edit_draw(filestruct *fileptr, const char *converted, int line, size_t from_col); int update_line(filestruct *fileptr, size_t index); -bool need_horizontal_scroll(const size_t old_column, const size_t new_column); +bool line_needs_update(const size_t old_column, const size_t new_column); int go_back_chunks(int nrows, filestruct **line, size_t *leftedge); int go_forward_chunks(int nrows, filestruct **line, size_t *leftedge); bool less_than_a_screenful(size_t was_lineno, size_t was_leftedge); diff --git a/src/winio.c b/src/winio.c index 84a7e9b0b74ac7fe92d84631b519312df02b7f88..3c0683660eae62ead03709397b1cc11f754c29f4 100644 --- a/src/winio.c +++ b/src/winio.c @@ -2715,9 +2715,10 @@ int update_line(filestruct *fileptr, size_t index) return 1; } -/* Check whether old_column and new_column are on different "pages" (or that - * the mark is on), which means that the relevant line needs to be redrawn. */ -bool need_horizontal_scroll(const size_t old_column, const size_t new_column) +/* Check whether the mark is on, or whether old_column and new_column are on + * different "pages" (in softwrap mode, only the former applies), which means + * that the relevant line needs to be redrawn. */ +bool line_needs_update(const size_t old_column, const size_t new_column) { #ifndef NANO_TINY if (openfile->mark_set) @@ -2934,7 +2935,7 @@ void edit_scroll(scroll_dir direction, int nrows) for (i = nrows; i > 0 && line != NULL; i--) { if ((i == nrows && direction == DOWNWARD) || (i == 1 && direction == UPWARD)) { - if (need_horizontal_scroll(openfile->placewewant, 0)) + if (line_needs_update(openfile->placewewant, 0)) update_line(line, (line == openfile->current) ? openfile->current_x : 0); } else @@ -3016,7 +3017,7 @@ void edit_redraw(filestruct *old_current) /* Update current if the mark is on or it has changed "page", or if it * differs from old_current and needs to be horizontally scrolled. */ - if (need_horizontal_scroll(was_pww, openfile->placewewant) || + if (line_needs_update(was_pww, openfile->placewewant) || (old_current != openfile->current && get_page_start(openfile->placewewant) > 0)) update_line(openfile->current, openfile->current_x);