Index: src/move.c =================================================================== --- src/move.c (revisión: 4629) +++ src/move.c (copia de trabajo) @@ -564,13 +564,13 @@ ) { bool onlastline = FALSE; - int extra = 0; + int amount, over = 0; + filestruct *line; /* If we're at the bottom of the file, get out. */ if (openfile->current == openfile->filebot) return; - assert(ISSET(SOFTWRAP) || openfile->current_y == openfile->current->lineno - openfile->edittop->lineno); /* Move the current line of the edit window down. */ @@ -581,11 +581,22 @@ if (ISSET(SOFTWRAP)) { if (openfile->current->lineno - openfile->edittop->lineno >= maxrows) onlastline = TRUE; - /* Compute the extra amount to scroll when the current line is overlong. */ - extra = (strlenpt(openfile->current->data) / COLS + openfile->current_y + 2 - editwinrows); + /* Compute the amount to scroll. */ + amount = (strlenpt(openfile->current->data) / COLS + openfile->current_y + 2 + + strlenpt(openfile->current->prev->data) / COLS - editwinrows); + line = openfile->edittop; + /* Reduce the amount when there are overlong lines at the top. */ + for (over = amount; over > 1; over--) { + amount -= strlenpt(line->data) / COLS; + line = line->next; + } + /* Assure a scroll when there is an overlong line at the end. */ + if ((openfile->current_y + strlenpt(openfile->current->prev->data) / COLS + 2 + + strlenpt(openfile->current->data) / COLS > editwinrows) && (amount < 1)) + amount = 1; } - /* If scroll_only is FALSE and if we're on the first line of the + /* If scroll_only is FALSE and if we're on the last line of the * edit window, scroll the edit window down one line if we're in * smooth scrolling mode, or down half a page if we're not. If * scroll_only is TRUE, scroll the edit window down one line @@ -597,13 +608,13 @@ ) { edit_scroll(DOWN_DIR, #ifndef NANO_TINY - (ISSET(SMOOTH_SCROLL) || scroll_only) ? 1 : + (ISSET(SMOOTH_SCROLL) || scroll_only) ? (amount ? amount : 1) : #endif editwinrows / 2 + 1); edit_refresh_needed = TRUE; - } else if (extra > 0) { - edit_scroll(DOWN_DIR, extra); + } else if (amount > 0) { + edit_scroll(DOWN_DIR, amount); edit_refresh_needed = TRUE; } /* If we're above the last line of the edit window, update the line Index: src/winio.c =================================================================== --- src/winio.c (revisión: 4629) +++ src/winio.c (copia de trabajo) @@ -2997,7 +2997,9 @@ /* If using soft wrapping, we want to scroll down enough to display the entire next line, if possible... */ - if (ISSET(SOFTWRAP) && direction == DOWN_DIR) { + +/* DEFEAT the extracuz computation for now; the amount should be okay already. */ + if (FALSE && ISSET(SOFTWRAP) && direction == DOWN_DIR) { #ifdef DEBUG fprintf(stderr, "Softwrap: Entering check for extracuzsoft\n"); #endif @@ -3041,7 +3043,7 @@ openfile->edittop = openfile->edittop->next; } /* Don't over-scroll on long lines */ - if (ISSET(SOFTWRAP)) { + if (ISSET(SOFTWRAP) && (direction == UP_DIR)) { ssize_t len = strlenpt(openfile->edittop->data) / COLS; i -= len; if (len > 0)