diff --git a/ChangeLog b/ChangeLog
index 3d1af7d27f8932faa5ba217232c9ce541e0741c1..d2ea86b151c749be55878d2a1c3866925d1441a9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,9 @@
 	* src/winio.c (edit_draw): Start and end regexes can be very similar;
 	so if a found start has been qualified as an end earlier, believe it
 	and skip to the next step.  This helps with Python's docstrings.
+	* src/winio.c (edit_draw): When the whole line has been coloured,
+	don't bother looking for any more starts.  This prevents some lines
+	from being erroneously marked as CENDAFTER instead of CWHOLELINE.
 
 2015-06-11  Benno Schulenberg  <bensberg@justemail.net>
 	* src/winio.c (get_key_buffer): Add some debugging code to make it
diff --git a/src/winio.c b/src/winio.c
index 286b750414a830b5e98d3eb361244490d8c9a3f1..b8f918bd3c9ad6ac5fb31bd20b622c2f6cc9a7c9 100644
--- a/src/winio.c
+++ b/src/winio.c
@@ -2492,7 +2492,7 @@ void edit_draw(filestruct *fileptr, const char *converted, int
 	for (; tmpcolor != NULL; tmpcolor = tmpcolor->next) {
 	    int x_start;
 		/* Starting column for mvwaddnstr.  Zero-based. */
-	    int paintlen;
+	    int paintlen = 0;
 		/* Number of chars to paint on this line.  There are
 		 * COLS characters on a whole line. */
 	    size_t index;
@@ -2673,6 +2673,10 @@ void edit_draw(filestruct *fileptr, const char *converted, int
 #endif
 		    }
 		    mvwaddnstr(edit, line, 0, converted, paintlen);
+		    /* If the whole line has been painted, don't bother
+		     * looking for any more starts. */
+		    if (paintlen < 0)
+			goto end_of_loop;
   step_two:
 		    /* Second step, we look for starts on this line. */
 		    start_col = 0;