diff --git a/src/winio.c b/src/winio.c
index b60caa11bc9fb25a6791b9c347fa26c260856206..1ba4a861c7c0d7aebb4a390205f13ef52b86890d 100644
--- a/src/winio.c
+++ b/src/winio.c
@@ -2473,25 +2473,24 @@ void edit_draw(filestruct *fileptr, const char *converted,
 			start_line->multidata[varnish->id] == CSTARTENDHERE))
 		goto step_two;
 
-	    /* Skip over a zero-length regex match. */
-	    if (startmatch.rm_so == startmatch.rm_eo)
-		goto tail_of_loop;
-
 	    /* Now start_line is the first line before fileptr containing
 	     * a start match.  Is there a start on that line not followed
 	     * by an end on that line? */
 	    while (TRUE) {
+		/* Begin searching for an end after the start match. */
 		index += startmatch.rm_eo;
+		/* If the start match is zero-length, don't get stuck. */
+		if (startmatch.rm_so == startmatch.rm_eo)
+		    index++;
+
+		/* If there is no end after this last start, good. */
 		if (regexec(varnish->end, start_line->data + index,
 				0, NULL, REG_NOTBOL) == REG_NOMATCH)
-		    /* No end found after this start. */
 		    break;
+		/* If there is no later start on this line, next step. */
 		if (regexec(varnish->start, start_line->data + index,
 				1, &startmatch, REG_NOTBOL) == REG_NOMATCH)
-		    /* No later start on this line. */
 		    goto step_two;
-		if (startmatch.rm_so == startmatch.rm_eo)
-		    index++;
 	    }
 	    /* Indeed, there is a start without an end on that line. */