diff options
Diffstat (limited to 'src/nvim/syntax.c')
-rw-r--r-- | src/nvim/syntax.c | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index 2df0e72f8f..ec54887246 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -827,8 +827,10 @@ static int syn_match_linecont(linenr_T lnum) if (syn_block->b_syn_linecont_prog != NULL) { regmatch.rmm_ic = syn_block->b_syn_linecont_ic; regmatch.regprog = syn_block->b_syn_linecont_prog; - return syn_regexec(®match, lnum, (colnr_T)0, - IF_SYN_TIME(&syn_block->b_syn_linecont_time)); + int r = syn_regexec(®match, lnum, (colnr_T)0, + IF_SYN_TIME(&syn_block->b_syn_linecont_time)); + syn_block->b_syn_linecont_prog = regmatch.regprog; + return r; } return FALSE; } @@ -1798,10 +1800,10 @@ syn_current_attr ( regmatch.rmm_ic = spp->sp_ic; regmatch.regprog = spp->sp_prog; - if (!syn_regexec(®match, - current_lnum, - (colnr_T)lc_col, - IF_SYN_TIME(&spp->sp_time))) { + int r = syn_regexec(®match, current_lnum, (colnr_T)lc_col, + IF_SYN_TIME(&spp->sp_time)); + spp->sp_prog = regmatch.regprog; + if (!r) { /* no match in this line, try another one */ spp->sp_startcol = MAXCOL; continue; @@ -2585,8 +2587,10 @@ find_endpos ( regmatch.rmm_ic = spp->sp_ic; regmatch.regprog = spp->sp_prog; - if (syn_regexec(®match, startpos->lnum, lc_col, - IF_SYN_TIME(&spp->sp_time))) { + int r = syn_regexec(®match, startpos->lnum, lc_col, + IF_SYN_TIME(&spp->sp_time)); + spp->sp_prog = regmatch.regprog; + if (r) { if (best_idx == -1 || regmatch.startpos[0].col < best_regmatch.startpos[0].col) { best_idx = idx; @@ -2614,10 +2618,10 @@ find_endpos ( lc_col = 0; regmatch.rmm_ic = spp_skip->sp_ic; regmatch.regprog = spp_skip->sp_prog; - if (syn_regexec(®match, startpos->lnum, lc_col, - IF_SYN_TIME(&spp_skip->sp_time)) - && regmatch.startpos[0].col - <= best_regmatch.startpos[0].col) { + int r = syn_regexec(®match, startpos->lnum, lc_col, + IF_SYN_TIME(&spp_skip->sp_time)); + spp_skip->sp_prog = regmatch.regprog; + if (r && regmatch.startpos[0].col <= best_regmatch.startpos[0].col) { /* Add offset to skip pattern match */ syn_add_end_off(&pos, ®match, spp_skip, SPO_ME_OFF, 1); |