diff options
Diffstat (limited to 'src/regexp_nfa.c')
| -rw-r--r-- | src/regexp_nfa.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/regexp_nfa.c b/src/regexp_nfa.c index 52f09ebbb7..4e4f5890fd 100644 --- a/src/regexp_nfa.c +++ b/src/regexp_nfa.c @@ -6121,12 +6121,14 @@ static long nfa_regtry(nfa_regprog_T *prog, colnr_T col) if (REG_MULTI) { struct multipos *mpos = &subs.synt.list.multi[i]; - /* Only accept single line matches. */ - if (mpos->start.lnum >= 0 && mpos->start.lnum == mpos->end.lnum) + // Only accept single line matches that are valid. + if (mpos->start.lnum >= 0 + && mpos->start.lnum == mpos->end.lnum + && mpos->end.col >= mpos->start.col) { re_extmatch_out->matches[i] = - vim_strnsave(reg_getline(mpos->start.lnum) - + mpos->start.col, - mpos->end.col - mpos->start.col); + vim_strnsave(reg_getline(mpos->start.lnum) + mpos->start.col, + mpos->end.col - mpos->start.col); + } } else { struct linepos *lpos = &subs.synt.list.line[i]; |