commit df7bba340fbf251a1383cef43db53c1a5f8238f8
parent db906ea121b179353432d993d69f3c7bc68c92b9
Author: Benno Schulenberg <bensberg@justemail.net>
Date: Wed, 26 Feb 2014 11:38:30 +0000
Scrolling an extra amount when softwrap is on and the current line runs off.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4611 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
Diffstat:
3 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -1,3 +1,9 @@
+2014-02-26 Benno Schulenberg <bensberg@justemail.net>
+ * src/move.c (do_down), src/winio.c (edit_scroll) - Scroll an
+ extra amount when softwrap is on and the current line would
+ otherwise run off the screen, and recalculate maxrows after
+ each scroll. Solves bug #27550 reported by Hannes Schueller.
+
2014-02-25 Benno Schulenberg <bensberg@justemail.net>
* NEWS - Fix some typos and wordings, and rewrap a few lines.
* src/global.c - Correcting some translator comments, removal
diff --git a/src/move.c b/src/move.c
@@ -564,6 +564,7 @@ void do_down(
)
{
bool onlastline = FALSE;
+ int extra = 0;
/* If we're at the bottom of the file, get out. */
if (openfile->current == openfile->filebot)
@@ -580,6 +581,8 @@ void do_down(
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);
}
/* If scroll_only is FALSE and if we're on the first line of the
@@ -599,6 +602,9 @@ void do_down(
editwinrows / 2 + 1);
edit_refresh_needed = TRUE;
+ } else if (extra > 0) {
+ edit_scroll(DOWN_DIR, extra);
+ edit_refresh_needed = TRUE;
}
/* If we're above the last line of the edit window, update the line
* we were on before and the line we're on now. The former needs to
diff --git a/src/winio.c b/src/winio.c
@@ -3115,6 +3115,7 @@ void edit_scroll(scroll_dir direction, ssize_t nlines)
openfile->current_x : 0);
foo = foo->next;
}
+ compute_maxrows();
}
/* Update any lines between old_current and current that need to be