From d5228b3d823934eb60e98409631886f6ef467b0d Mon Sep 17 00:00:00 2001
From: David Lawrence Ramsey <pooka109@gmail.com>
Date: Fri, 26 May 2006 03:04:24 +0000
Subject: [PATCH] in edit_redraw(), fix problem where not all lines would be
 updated properly if we'd scrolled off the screen and the mark was on

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3568 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
---
 ChangeLog   |  3 +++
 src/winio.c | 35 ++++++++++++++++++++++++++++++++++-
 2 files changed, 37 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 79910ba9..07c0efcf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -304,6 +304,9 @@ CVS code -
 	  well as single-line ones.  This avoids a segfault when trying
 	  to color e.g. "start="$" end="$"". (DLR, found by Trevor
 	  Caira)
+  edit_redraw()
+	- Fix problem where not all lines would be updated properly if
+	  we'd scrolled off the screen and the mark was on. (DLR)
   do_credits()
 	- Update the last copyright notice to include 2006. (DLR)
 - configure.ac:
diff --git a/src/winio.c b/src/winio.c
index 51b7033c..b7246f1f 100644
--- a/src/winio.c
+++ b/src/winio.c
@@ -2807,7 +2807,7 @@ void edit_redraw(const filestruct *old_current, size_t old_pww)
 {
     bool do_redraw = need_vertical_update(0) ||
 	need_vertical_update(old_pww);
-    const filestruct *foo;
+    const filestruct *foo = NULL;
 
     /* If either old_current or current is offscreen, scroll the edit
      * window until it's onscreen and get out. */
@@ -2819,6 +2819,26 @@ void edit_redraw(const filestruct *old_current, size_t old_pww)
 	filestruct *old_edittop = openfile->edittop;
 	ssize_t nlines;
 
+#ifndef NANO_TINY
+	/* If the mark is on, update all the lines between old_current
+	 * and the old last line of the edit window. */
+	if (openfile->mark_set) {
+	    ssize_t old_last_lineno = (old_edittop->lineno +
+		editwinrows <= openfile->filebot->lineno) ?
+		old_edittop->lineno + editwinrows :
+		openfile->filebot->lineno;
+
+	    foo = old_current;
+
+	    while (foo->lineno != old_last_lineno) {
+		update_line(foo, 0);
+
+		foo = (foo->lineno > old_last_lineno) ? foo->prev :
+			foo->next;
+	    }
+	}
+#endif /* !NANO_TINY */
+
 	/* Put edittop in range of current, get the difference in lines
 	 * between the original edittop and the current edittop, and
 	 * then restore the original edittop. */
@@ -2844,6 +2864,19 @@ void edit_redraw(const filestruct *old_current, size_t old_pww)
 	else
 	    edit_scroll(DOWN, nlines);
 
+#ifndef NANO_TINY
+	/* If the mark is on, update all the lines between the old last
+	 * line of the edit window and current. */
+	if (openfile->mark_set) {
+	    while (foo != openfile->current) {
+		update_line(foo, 0);
+
+		foo = (foo->lineno > openfile->current->lineno) ?
+			foo->prev : foo->next;
+	    }
+	}
+#endif /* !NANO_TINY */
+
 	return;
     }
 
-- 
GitLab