diff --git a/src/winio.c b/src/winio.c index 5a034a34..fa3ae715 100644 --- a/src/winio.c +++ b/src/winio.c @@ -2524,10 +2524,14 @@ void draw_row(int row, const char *converted, linestruct *line, size_t from_col) match.rm_eo += index; index = match.rm_eo; - /* If the matching part is not visible, skip it. */ - if (match.rm_eo <= from_x || match.rm_so >= till_x) + /* If the match is offscreen to the left, skip to next. */ + if (match.rm_eo <= from_x) continue; + /* If the match is off to the right, this rule is done. */ + if (match.rm_so >= till_x) + break; + start_col = (match.rm_so <= from_x) ? 0 : wideness(line->data, match.rm_so) - from_col;