mirror of
https://github.com/neovim/neovim.git
synced 2025-09-07 03:48:18 +00:00
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 vim/vim#10938)
753aead960
Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
@@ -6256,13 +6256,12 @@ static bool regmatch(uint8_t *scan, const proftime_T *tm, int *timed_out)
|
|||||||
|
|
||||||
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;
|
||||||
int vcol = 0;
|
if (REG_MULTI && (lnum <= 0 || lnum > wp->w_buffer->b_ml.ml_line_count)) {
|
||||||
|
lnum = 1;
|
||||||
if (lnum >= 0 && lnum <= wp->w_buffer->b_ml.ml_line_count) {
|
|
||||||
vcol = win_linetabsize(wp, lnum, (char *)rex.line,
|
|
||||||
(colnr_T)(rex.input - rex.line));
|
|
||||||
}
|
}
|
||||||
|
int vcol = win_linetabsize(wp, lnum, (char *)rex.line,
|
||||||
|
(colnr_T)(rex.input - rex.line));
|
||||||
if (!re_num_cmp((uint32_t)vcol + 1, scan)) {
|
if (!re_num_cmp((uint32_t)vcol + 1, scan)) {
|
||||||
status = RA_NOMATCH;
|
status = RA_NOMATCH;
|
||||||
}
|
}
|
||||||
@@ -15105,12 +15104,11 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, regsubs_T *subm
|
|||||||
result = col > t->state->val * ts;
|
result = col > t->state->val * ts;
|
||||||
}
|
}
|
||||||
if (!result) {
|
if (!result) {
|
||||||
linenr_T lnum = rex.reg_firstlnum + rex.lnum;
|
linenr_T lnum = REG_MULTI ? rex.reg_firstlnum + rex.lnum : 1;
|
||||||
int vcol = 0;
|
if (REG_MULTI && (lnum <= 0 || lnum > wp->w_buffer->b_ml.ml_line_count)) {
|
||||||
|
lnum = 1;
|
||||||
if (lnum >= 0 && lnum <= wp->w_buffer->b_ml.ml_line_count) {
|
|
||||||
vcol = win_linetabsize(wp, lnum, (char *)rex.line, col);
|
|
||||||
}
|
}
|
||||||
|
int vcol = win_linetabsize(wp, lnum, (char *)rex.line, col);
|
||||||
assert(t->state->val >= 0);
|
assert(t->state->val >= 0);
|
||||||
result = nfa_re_num_cmp((uintmax_t)t->state->val, op, (uintmax_t)vcol + 1);
|
result = nfa_re_num_cmp((uintmax_t)t->state->val, op, (uintmax_t)vcol + 1);
|
||||||
}
|
}
|
||||||
|
@@ -1151,7 +1151,13 @@ endfunc
|
|||||||
" enddef
|
" enddef
|
||||||
|
|
||||||
func Test_compare_column_matchstr()
|
func Test_compare_column_matchstr()
|
||||||
|
" do some search in text to set the line number, it should be ignored in
|
||||||
|
" matchstr().
|
||||||
enew
|
enew
|
||||||
|
call 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
|
||||||
|
Reference in New Issue
Block a user