forked from aniani/vim
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)
This commit is contained in:
@@ -3441,11 +3441,13 @@ regmatch(
|
|||||||
case RE_VCOL:
|
case RE_VCOL:
|
||||||
{
|
{
|
||||||
win_T *wp = rex.reg_win == NULL ? curwin : rex.reg_win;
|
win_T *wp = rex.reg_win == NULL ? curwin : rex.reg_win;
|
||||||
linenr_T lnum = rex.reg_firstlnum + rex.lnum;
|
linenr_T lnum = REG_MULTI ? rex.reg_firstlnum + rex.lnum : 1;
|
||||||
long_u vcol = 0;
|
long_u vcol;
|
||||||
|
|
||||||
if (lnum >= 0 && lnum <= wp->w_buffer->b_ml.ml_line_count)
|
if (REG_MULTI && (lnum <= 0
|
||||||
vcol = (long_u)win_linetabsize(wp, lnum, rex.line,
|
|| lnum > wp->w_buffer->b_ml.ml_line_count))
|
||||||
|
lnum = 1;
|
||||||
|
vcol = (long_u)win_linetabsize(wp, lnum, rex.line,
|
||||||
(colnr_T)(rex.input - rex.line));
|
(colnr_T)(rex.input - rex.line));
|
||||||
if (!re_num_cmp(vcol + 1, scan))
|
if (!re_num_cmp(vcol + 1, scan))
|
||||||
status = RA_NOMATCH;
|
status = RA_NOMATCH;
|
||||||
|
@@ -6775,12 +6775,14 @@ nfa_regmatch(
|
|||||||
}
|
}
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
linenr_T lnum = rex.reg_firstlnum + rex.lnum;
|
linenr_T lnum = REG_MULTI
|
||||||
long_u vcol = 0;
|
? rex.reg_firstlnum + rex.lnum : 1;
|
||||||
|
long_u vcol;
|
||||||
|
|
||||||
if (lnum >= 0
|
if (REG_MULTI && (lnum <= 0
|
||||||
&& lnum <= wp->w_buffer->b_ml.ml_line_count)
|
|| lnum > wp->w_buffer->b_ml.ml_line_count))
|
||||||
vcol = (long_u)win_linetabsize(wp, lnum,
|
lnum = 1;
|
||||||
|
vcol = (long_u)win_linetabsize(wp, lnum,
|
||||||
rex.line, col);
|
rex.line, col);
|
||||||
result = nfa_re_num_cmp(t->state->val, op, vcol + 1);
|
result = nfa_re_num_cmp(t->state->val, op, vcol + 1);
|
||||||
}
|
}
|
||||||
|
@@ -1145,7 +1145,13 @@ def Test_compare_columns()
|
|||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_compare_column_matchstr()
|
def Test_compare_column_matchstr()
|
||||||
|
# do some search in text to set the line number, it should be ignored in
|
||||||
|
# matchstr().
|
||||||
enew
|
enew
|
||||||
|
setline(1, ['one', 'two', 'three'])
|
||||||
|
:3
|
||||||
|
:/ee
|
||||||
|
bwipe!
|
||||||
set re=1
|
set re=1
|
||||||
call assert_equal('aaa', matchstr('aaaaaaaaaaaaaaaaaaaa', '.*\%<5v'))
|
call assert_equal('aaa', matchstr('aaaaaaaaaaaaaaaaaaaa', '.*\%<5v'))
|
||||||
set re=2
|
set re=2
|
||||||
|
@@ -703,6 +703,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
414,
|
||||||
/**/
|
/**/
|
||||||
413,
|
413,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user