mirror of
https://github.com/neovim/neovim.git
synced 2025-09-05 19:08:15 +00:00
vim-patch:9.0.0407: matchstr() does match column offset
Problem: matchstr() does match column offset. (Yasuhiro Matsumoto)
Solution: Accept line number zero. (closes vim/vim#10938)
75a115e8d6
Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
@@ -6259,7 +6259,7 @@ static bool regmatch(uint8_t *scan, const proftime_T *tm, int *timed_out)
|
||||
linenr_T lnum = rex.reg_firstlnum + rex.lnum;
|
||||
int vcol = 0;
|
||||
|
||||
if (lnum > 0 && lnum <= wp->w_buffer->b_ml.ml_line_count) {
|
||||
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));
|
||||
}
|
||||
@@ -15108,7 +15108,7 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, regsubs_T *subm
|
||||
linenr_T lnum = rex.reg_firstlnum + rex.lnum;
|
||||
int vcol = 0;
|
||||
|
||||
if (lnum > 0 && lnum <= wp->w_buffer->b_ml.ml_line_count) {
|
||||
if (lnum >= 0 && lnum <= wp->w_buffer->b_ml.ml_line_count) {
|
||||
vcol = win_linetabsize(wp, lnum, (char *)rex.line, col);
|
||||
}
|
||||
assert(t->state->val >= 0);
|
||||
|
@@ -30,11 +30,13 @@ endfunc
|
||||
func Test_equivalence_re1()
|
||||
set re=1
|
||||
call s:equivalence_test()
|
||||
set re=0
|
||||
endfunc
|
||||
|
||||
func Test_equivalence_re2()
|
||||
set re=2
|
||||
call s:equivalence_test()
|
||||
set re=0
|
||||
endfunc
|
||||
|
||||
func Test_recursive_substitute()
|
||||
@@ -67,6 +69,7 @@ func Test_eow_with_optional()
|
||||
let actual = matchlist('abc def', '\(abc\>\)\?\s*\(def\)')
|
||||
call assert_equal(expected, actual)
|
||||
endfor
|
||||
set re=0
|
||||
endfunc
|
||||
|
||||
func Test_backref()
|
||||
@@ -1147,4 +1150,14 @@ endfunc
|
||||
" prop_type_delete('name')
|
||||
" enddef
|
||||
|
||||
func Test_compare_column_matchstr()
|
||||
enew
|
||||
set re=1
|
||||
call assert_equal('aaa', matchstr('aaaaaaaaaaaaaaaaaaaa', '.*\%<5v'))
|
||||
set re=2
|
||||
call assert_equal('aaa', matchstr('aaaaaaaaaaaaaaaaaaaa', '.*\%<5v'))
|
||||
set re=0
|
||||
endfunc
|
||||
|
||||
|
||||
" vim: shiftwidth=2 sts=2 expandtab
|
||||
|
Reference in New Issue
Block a user