From 438cb110ff8a2ff8e3d416b89705f37390b6e892 Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <bensberg@justemail.net>
Date: Wed, 25 Nov 2015 09:10:02 +0000
Subject: [PATCH] Refreshing the whole edit window only when there are
 multiline regexes, and checking for this just once for every burst of
 keystrokes.

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5439 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
---
 ChangeLog  |  6 ++++++
 src/nano.c | 11 ++++++-----
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index dfc5ceb4..2bab1d75 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2015-11-25  Benno Schulenberg  <bensberg@justemail.net>
+	* src/nano.c (do_output): Refreshing the whole edit window (instead
+	of just the current line) is not needed for any kind of syntax, but
+	only when there are multiline regexes.  And check for this not on
+	every keystroke in a burst, but just once.
+
 2015-11-24  Benno Schulenberg  <bensberg@justemail.net>
 	* doc/syntax/makefile.nanorc: Also recognize the extensions .make and
 	.mk as Makefiles.  Suggested by Emmanuel Bourg in Debian bug #804845.
diff --git a/src/nano.c b/src/nano.c
index 9c95ed81..421ba3f9 100644
--- a/src/nano.c
+++ b/src/nano.c
@@ -2072,14 +2072,15 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
 	    if (do_wrap(openfile->current))
 		edit_refresh_needed = TRUE;
 #endif
+    }
 
 #ifndef DISABLE_COLOR
-	/* If color syntaxes are available and turned on, we need to
-	 * call edit_refresh(). */
-	if (openfile->colorstrings != NULL && !ISSET(NO_COLOR_SYNTAX))
-	    edit_refresh_needed = TRUE;
+    /* If syntax highlighting is turned on and there are multiline regexes,
+     * the edit window will need to be refreshed. */
+    if (!ISSET(NO_COLOR_SYNTAX) && openfile->syntax &&
+		openfile->syntax->nmultis > 0)
+	edit_refresh_needed = TRUE;
 #endif
-    }
 
 #ifndef NANO_TINY
     /* Well, we might also need a full refresh if we've changed the
-- 
GitLab