Skip to content

Commit 753aead

Browse files
committed
patch 9.0.0414: matchstr() still does not match column offset
Problem: matchstr() still does not match column offset when done after a text search. Solution: Only use the line number for a multi-line search. Fix the test. (closes #10938)
1 parent b0d12e6 commit 753aead

4 files changed

Lines changed: 22 additions & 10 deletions

File tree

src/regexp_bt.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3441,11 +3441,13 @@ regmatch(
34413441
case RE_VCOL:
34423442
{
34433443
win_T *wp = rex.reg_win == NULL ? curwin : rex.reg_win;
3444-
linenr_T lnum = rex.reg_firstlnum + rex.lnum;
3445-
long_u vcol = 0;
3444+
linenr_T lnum = REG_MULTI ? rex.reg_firstlnum + rex.lnum : 1;
3445+
long_u vcol;
34463446

3447-
if (lnum >= 0 && lnum <= wp->w_buffer->b_ml.ml_line_count)
3448-
vcol = (long_u)win_linetabsize(wp, lnum, rex.line,
3447+
if (REG_MULTI && (lnum <= 0
3448+
|| lnum > wp->w_buffer->b_ml.ml_line_count))
3449+
lnum = 1;
3450+
vcol = (long_u)win_linetabsize(wp, lnum, rex.line,
34493451
(colnr_T)(rex.input - rex.line));
34503452
if (!re_num_cmp(vcol + 1, scan))
34513453
status = RA_NOMATCH;

src/regexp_nfa.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6775,12 +6775,14 @@ nfa_regmatch(
67756775
}
67766776
if (!result)
67776777
{
6778-
linenr_T lnum = rex.reg_firstlnum + rex.lnum;
6779-
long_u vcol = 0;
6780-
6781-
if (lnum >= 0
6782-
&& lnum <= wp->w_buffer->b_ml.ml_line_count)
6783-
vcol = (long_u)win_linetabsize(wp, lnum,
6778+
linenr_T lnum = REG_MULTI
6779+
? rex.reg_firstlnum + rex.lnum : 1;
6780+
long_u vcol;
6781+
6782+
if (REG_MULTI && (lnum <= 0
6783+
|| lnum > wp->w_buffer->b_ml.ml_line_count))
6784+
lnum = 1;
6785+
vcol = (long_u)win_linetabsize(wp, lnum,
67846786
rex.line, col);
67856787
result = nfa_re_num_cmp(t->state->val, op, vcol + 1);
67866788
}

src/testdir/test_regexp_latin.vim

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,7 +1145,13 @@ def Test_compare_columns()
11451145
enddef
11461146

11471147
def Test_compare_column_matchstr()
1148+
# do some search in text to set the line number, it should be ignored in
1149+
# matchstr().
11481150
enew
1151+
setline(1, ['one', 'two', 'three'])
1152+
:3
1153+
:/ee
1154+
bwipe!
11491155
set re=1
11501156
call assert_equal('aaa', matchstr('aaaaaaaaaaaaaaaaaaaa', '.*\%<5v'))
11511157
set re=2

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,8 @@ static char *(features[]) =
703703

704704
static int included_patches[] =
705705
{ /* Add new patch number below this line */
706+
/**/
707+
414,
706708
/**/
707709
413,
708710
/**/

0 commit comments

Comments
 (0)