commit 258497fb5c28a2ba29b65f84b2737d483edf3da3
parent 107e8163242a1dbe58b093d3fe53b3eead7281ea
Author: David Lawrence Ramsey <pooka109@gmail.com>
Date: Mon, 1 Aug 2005 21:17:38 +0000
fix misplaced code in previous edit_scroll() fix
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2970 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
Diffstat:
1 file changed, 14 insertions(+), 13 deletions(-)
diff --git a/src/winio.c b/src/winio.c
@@ -3507,10 +3507,19 @@ void edit_scroll(scroll_dir direction, ssize_t nlines)
}
/* Limit nlines to a minimum of the number of lines we could scroll,
- * and to a maximum of the number of lines in the edit window. */
+ * and to a maximum of the number of lines in the edit window, minus
+ * one. Don't bother scrolling zero lines or the number of lines in
+ * the edit window; in both cases, get out, and in the latter case,
+ * call edit_refresh() beforehand. */
nlines -= i;
- if (nlines > editwinrows)
- nlines = editwinrows;
+
+ if (nlines == 0)
+ return;
+
+ if (nlines >= editwinrows) {
+ edit_refresh();
+ return;
+ }
/* Scroll the text of the edit window up or down nlines lines,
* depending on the value of direction. */
@@ -3537,14 +3546,6 @@ void edit_scroll(scroll_dir direction, ssize_t nlines)
if (nlines > editwinrows)
nlines = editwinrows;
- /* If we need to redraw the entire edit window, don't bother
- * scrolling every line offscreen. Just call edit_refresh() and get
- * out. */
- if (nlines == editwinrows) {
- edit_refresh();
- return;
- }
-
/* If we scrolled up, we're on the line before the scrolled
* region. */
foo = openfile->edittop;
@@ -3605,8 +3606,8 @@ void edit_redraw(const filestruct *old_current, size_t old_pww)
openfile->edittop = old_edittop;
- /* Scroll the edit window until edittop is in range of
- * current. */
+ /* Scroll the edit window up or down until edittop is in range
+ * of current. */
if (nlines < 0)
edit_scroll(UP, -nlines);
else