diff --git a/src/move.c b/src/move.c index 1657bda9..7338df12 100644 --- a/src/move.c +++ b/src/move.c @@ -556,8 +556,8 @@ void do_scroll_down(void) if (editwinrows > 1 && (openfile->edittop->next != NULL #ifndef NANO_TINY - || chunk_for(openfile->firstcolumn, openfile->edittop) < - number_of_chunks_in(openfile->edittop) + || (ISSET(SOFTWRAP) && (number_of_chunks_in(openfile->edittop) > + chunk_for(openfile->firstcolumn, openfile->edittop))) #endif )) edit_scroll(FORWARD); diff --git a/src/winio.c b/src/winio.c index 8f1f8c76..ef24f6a5 100644 --- a/src/winio.c +++ b/src/winio.c @@ -3098,31 +3098,25 @@ size_t get_chunk_and_edge(size_t column, linestruct *line, size_t *leftedge) * relative to the first row (zero-based). */ size_t chunk_for(size_t column, linestruct *line) { - if (ISSET(SOFTWRAP)) - return get_chunk_and_edge(column, line, NULL); - else - return 0; + return get_chunk_and_edge(column, line, NULL); } /* Return the leftmost column of the softwrapped chunk of the given line that * column is on. */ size_t leftedge_for(size_t column, linestruct *line) { - if (ISSET(SOFTWRAP)) { - size_t leftedge; + size_t leftedge; - get_chunk_and_edge(column, line, &leftedge); + get_chunk_and_edge(column, line, &leftedge); - return leftedge; - } else - return 0; + return leftedge; } /* Return the row of the last softwrapped chunk of the given line, relative to * the first row (zero-based). */ size_t number_of_chunks_in(linestruct *line) { - return chunk_for((size_t)-1, line); + return get_chunk_and_edge((size_t)-1, line, NULL); } /* Ensure that firstcolumn is at the starting column of the softwrapped chunk