tweaks: reshuffle three conditions into a better order
When a zero-length match is beyond the width of the screen, there is no point in continuing evaluating the rule, so the check for "offscreen to the right" needs to come first. The check for a zero-width match needs to come second because otherwise we would get stuck on such a match when it is offscreen to the left.master
parent
6cbb7bc443
commit
0508520b47
20
src/winio.c
20
src/winio.c
|
@ -2513,25 +2513,25 @@ void draw_row(int row, const char *converted, linestruct *line, size_t from_col)
|
||||||
&match, (index == 0) ? 0 : REG_NOTBOL) != 0)
|
&match, (index == 0) ? 0 : REG_NOTBOL) != 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* If the match is of length zero, skip over it. */
|
|
||||||
if (match.rm_so == match.rm_eo) {
|
|
||||||
index = step_right(line->data, index + match.rm_eo);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Translate the match to the beginning of the line. */
|
/* Translate the match to the beginning of the line. */
|
||||||
match.rm_so += index;
|
match.rm_so += index;
|
||||||
match.rm_eo += index;
|
match.rm_eo += index;
|
||||||
index = match.rm_eo;
|
index = match.rm_eo;
|
||||||
|
|
||||||
|
/* If the match is offscreen to the right, this rule is done. */
|
||||||
|
if (match.rm_so >= till_x)
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* If the match has length zero, advance over it. */
|
||||||
|
if (match.rm_so == match.rm_eo) {
|
||||||
|
index = step_right(line->data, index);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
/* If the match is offscreen to the left, skip to next. */
|
/* If the match is offscreen to the left, skip to next. */
|
||||||
if (match.rm_eo <= from_x)
|
if (match.rm_eo <= from_x)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* If the match is off to the right, this rule is done. */
|
|
||||||
if (match.rm_so >= till_x)
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (match.rm_so > from_x)
|
if (match.rm_so > from_x)
|
||||||
start_col = wideness(line->data, match.rm_so) - from_col;
|
start_col = wideness(line->data, match.rm_so) - from_col;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue