From a898fa5dcc7ecf7cca9d8c320dcd34c08c18338a Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <bensberg@justemail.net>
Date: Mon, 9 Jan 2017 19:14:51 +0100
Subject: [PATCH] tweaks: if there is no end match, there is nothing to paint

When there is no end match after a start, it is pointless to look
for any more starts because also they will not have any end match,
so nothing will get painted -- just cut the loop short.
---
 src/winio.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/winio.c b/src/winio.c
index 194d716f..7509a2cc 100644
--- a/src/winio.c
+++ b/src/winio.c
@@ -2504,9 +2504,10 @@ void edit_draw(filestruct *fileptr, const char *converted,
 				 1, &endmatch, 0) == REG_NOMATCH)
 		end_line = end_line->next;
 
-	    /* If no end was found, or it is too early, next step. */
+	    /* If there is no end, there is nothing to paint. */
 	    if (end_line == NULL)
-		goto step_two;
+		goto tail_of_loop;
+	    /* If the end is scrolled off to the left, next step. */
 	    if (end_line == fileptr && endmatch.rm_eo <= from_x) {
 		fileptr->multidata[varnish->id] = CBEGINBEFORE;
 		goto step_two;
-- 
GitLab