mirror of
https://github.com/neovim/neovim.git
synced 2025-09-07 11:58:17 +00:00
Merge pull request #29759 from zeertzjq/vim-9.0.0228
vim-patch:9.0.{0228,0407,0414}
This commit is contained in:
@@ -6254,15 +6254,20 @@ static bool regmatch(uint8_t *scan, const proftime_T *tm, int *timed_out)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RE_VCOL:
|
case RE_VCOL: {
|
||||||
if (!re_num_cmp((unsigned)win_linetabsize(rex.reg_win == NULL ? curwin : rex.reg_win,
|
win_T *wp = rex.reg_win == NULL ? curwin : rex.reg_win;
|
||||||
rex.reg_firstlnum + rex.lnum,
|
linenr_T lnum = REG_MULTI ? rex.reg_firstlnum + rex.lnum : 1;
|
||||||
(char *)rex.line,
|
if (REG_MULTI && (lnum <= 0 || lnum > wp->w_buffer->b_ml.ml_line_count)) {
|
||||||
(colnr_T)(rex.input - rex.line)) + 1,
|
lnum = 1;
|
||||||
scan)) {
|
}
|
||||||
|
int vcol = win_linetabsize(wp, lnum, (char *)rex.line,
|
||||||
|
(colnr_T)(rex.input - rex.line));
|
||||||
|
if (!re_num_cmp((uint32_t)vcol + 1, scan)) {
|
||||||
status = RA_NOMATCH;
|
status = RA_NOMATCH;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case BOW: // \<word; rex.input points to w
|
case BOW: // \<word; rex.input points to w
|
||||||
if (c == NUL) { // Can't match at end of line
|
if (c == NUL) { // Can't match at end of line
|
||||||
@@ -15099,9 +15104,13 @@ 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) {
|
||||||
int lts = win_linetabsize(wp, rex.reg_firstlnum + rex.lnum, (char *)rex.line, col);
|
linenr_T lnum = REG_MULTI ? rex.reg_firstlnum + rex.lnum : 1;
|
||||||
|
if (REG_MULTI && (lnum <= 0 || lnum > wp->w_buffer->b_ml.ml_line_count)) {
|
||||||
|
lnum = 1;
|
||||||
|
}
|
||||||
|
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)lts + 1);
|
result = nfa_re_num_cmp((uintmax_t)t->state->val, op, (uintmax_t)vcol + 1);
|
||||||
}
|
}
|
||||||
if (result) {
|
if (result) {
|
||||||
add_here = true;
|
add_here = true;
|
||||||
|
@@ -28,58 +28,47 @@ func s:equivalence_test()
|
|||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_equivalence_re1()
|
func Test_equivalence_re1()
|
||||||
throw 'skipped: Nvim does not support enc=latin1'
|
|
||||||
set re=1
|
set re=1
|
||||||
call s:equivalence_test()
|
call s:equivalence_test()
|
||||||
|
set re=0
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_equivalence_re2()
|
func Test_equivalence_re2()
|
||||||
throw 'skipped: Nvim does not support enc=latin1'
|
|
||||||
set re=2
|
set re=2
|
||||||
call s:equivalence_test()
|
call s:equivalence_test()
|
||||||
|
set re=0
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_range_with_newline()
|
func Test_recursive_substitute()
|
||||||
new
|
new
|
||||||
call setline(1, "a")
|
s/^/\=execute("s#^##gn")
|
||||||
call assert_equal(0, search("[ -*\\n- ]"))
|
" check we are now not in the sandbox
|
||||||
call assert_equal(0, search("[ -*\\t-\\n]"))
|
call setwinvar(1, 'myvar', 1)
|
||||||
bwipe!
|
bwipe!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_pattern_compile_speed()
|
func Test_nested_backrefs()
|
||||||
CheckOption spellcapcheck
|
" Check example in change.txt.
|
||||||
CheckFunction reltimefloat
|
new
|
||||||
|
for re in range(0, 2)
|
||||||
|
exe 'set re=' . re
|
||||||
|
call setline(1, 'aa ab x')
|
||||||
|
1s/\(\(a[a-d] \)*\)\(x\)/-\1- -\2- -\3-/
|
||||||
|
call assert_equal('-aa ab - -ab - -x-', getline(1))
|
||||||
|
|
||||||
let start = reltime()
|
call assert_equal('-aa ab - -ab - -x-', substitute('aa ab x', '\(\(a[a-d] \)*\)\(x\)', '-\1- -\2- -\3-', ''))
|
||||||
" this used to be very slow, not it should be about a second
|
endfor
|
||||||
set spc=\\v(((((Nxxxxxxx&&xxxx){179})+)+)+){179}
|
bwipe!
|
||||||
call assert_inrange(0.01, 10.0, reltimefloat(reltime(start)))
|
set re=0
|
||||||
set spc=
|
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_get_equi_class()
|
func Test_eow_with_optional()
|
||||||
new
|
let expected = ['abc def', 'abc', 'def', '', '', '', '', '', '', '']
|
||||||
" Incomplete equivalence class caused invalid memory access
|
for re in range(0, 2)
|
||||||
s/^/[[=
|
exe 'set re=' . re
|
||||||
call assert_equal(1, search(getline(1)))
|
let actual = matchlist('abc def', '\(abc\>\)\?\s*\(def\)')
|
||||||
s/.*/[[.
|
call assert_equal(expected, actual)
|
||||||
call assert_equal(1, search(getline(1)))
|
endfor
|
||||||
endfunc
|
|
||||||
|
|
||||||
func Test_rex_init()
|
|
||||||
set noincsearch
|
|
||||||
set re=1
|
|
||||||
new
|
|
||||||
setlocal iskeyword=a-z
|
|
||||||
call setline(1, ['abc', 'ABC'])
|
|
||||||
call assert_equal(1, search('[[:keyword:]]'))
|
|
||||||
new
|
|
||||||
setlocal iskeyword=A-Z
|
|
||||||
call setline(1, ['abc', 'ABC'])
|
|
||||||
call assert_equal(2, search('[[:keyword:]]'))
|
|
||||||
bwipe!
|
|
||||||
bwipe!
|
|
||||||
set re=0
|
set re=0
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
@@ -144,6 +133,50 @@ func Test_out_of_memory()
|
|||||||
call assert_fails('call search("\\v((n||<)+);")', 'E363:')
|
call assert_fails('call search("\\v((n||<)+);")', 'E363:')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_get_equi_class()
|
||||||
|
new
|
||||||
|
" Incomplete equivalence class caused invalid memory access
|
||||||
|
s/^/[[=
|
||||||
|
call assert_equal(1, search(getline(1)))
|
||||||
|
s/.*/[[.
|
||||||
|
call assert_equal(1, search(getline(1)))
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_rex_init()
|
||||||
|
set noincsearch
|
||||||
|
set re=1
|
||||||
|
new
|
||||||
|
setlocal iskeyword=a-z
|
||||||
|
call setline(1, ['abc', 'ABC'])
|
||||||
|
call assert_equal(1, search('[[:keyword:]]'))
|
||||||
|
new
|
||||||
|
setlocal iskeyword=A-Z
|
||||||
|
call setline(1, ['abc', 'ABC'])
|
||||||
|
call assert_equal(2, search('[[:keyword:]]'))
|
||||||
|
bwipe!
|
||||||
|
bwipe!
|
||||||
|
set re=0
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_range_with_newline()
|
||||||
|
new
|
||||||
|
call setline(1, "a")
|
||||||
|
call assert_equal(0, search("[ -*\\n- ]"))
|
||||||
|
call assert_equal(0, search("[ -*\\t-\\n]"))
|
||||||
|
bwipe!
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_pattern_compile_speed()
|
||||||
|
CheckOption spellcapcheck
|
||||||
|
CheckFunction reltimefloat
|
||||||
|
|
||||||
|
let start = reltime()
|
||||||
|
" this used to be very slow, not it should be about a second
|
||||||
|
set spc=\\v(((((Nxxxxxxx&&xxxx){179})+)+)+){179}
|
||||||
|
call assert_inrange(0.01, 10.0, reltimefloat(reltime(start)))
|
||||||
|
set spc=
|
||||||
|
endfunc
|
||||||
|
|
||||||
" Tests for regexp patterns without multi-byte support.
|
" Tests for regexp patterns without multi-byte support.
|
||||||
func Test_regexp_single_line_pat()
|
func Test_regexp_single_line_pat()
|
||||||
" tl is a List of Lists with:
|
" tl is a List of Lists with:
|
||||||
@@ -1105,4 +1138,32 @@ func Test_recursive_substitute_expr()
|
|||||||
delfunc Repl
|
delfunc Repl
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" def Test_compare_columns()
|
||||||
|
" # this was using a line below the last line
|
||||||
|
" enew
|
||||||
|
" setline(1, ['', ''])
|
||||||
|
" prop_type_add('name', {highlight: 'ErrorMsg'})
|
||||||
|
" prop_add(1, 1, {length: 1, type: 'name'})
|
||||||
|
" search('\%#=1\%>.l\n.*\%<2v', 'nW')
|
||||||
|
" search('\%#=2\%>.l\n.*\%<2v', 'nW')
|
||||||
|
" bwipe!
|
||||||
|
" prop_type_delete('name')
|
||||||
|
" enddef
|
||||||
|
|
||||||
|
func Test_compare_column_matchstr()
|
||||||
|
" do some search in text to set the line number, it should be ignored in
|
||||||
|
" matchstr().
|
||||||
|
enew
|
||||||
|
call setline(1, ['one', 'two', 'three'])
|
||||||
|
:3
|
||||||
|
:/ee
|
||||||
|
bwipe!
|
||||||
|
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
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
@@ -188,38 +188,6 @@ func Test_classes_re2()
|
|||||||
set re=0
|
set re=0
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_recursive_substitute()
|
|
||||||
new
|
|
||||||
s/^/\=execute("s#^##gn")
|
|
||||||
" check we are now not in the sandbox
|
|
||||||
call setwinvar(1, 'myvar', 1)
|
|
||||||
bwipe!
|
|
||||||
endfunc
|
|
||||||
|
|
||||||
func Test_nested_backrefs()
|
|
||||||
" Check example in change.txt.
|
|
||||||
new
|
|
||||||
for re in range(0, 2)
|
|
||||||
exe 'set re=' . re
|
|
||||||
call setline(1, 'aa ab x')
|
|
||||||
1s/\(\(a[a-d] \)*\)\(x\)/-\1- -\2- -\3-/
|
|
||||||
call assert_equal('-aa ab - -ab - -x-', getline(1))
|
|
||||||
|
|
||||||
call assert_equal('-aa ab - -ab - -x-', substitute('aa ab x', '\(\(a[a-d] \)*\)\(x\)', '-\1- -\2- -\3-', ''))
|
|
||||||
endfor
|
|
||||||
bwipe!
|
|
||||||
set re=0
|
|
||||||
endfunc
|
|
||||||
|
|
||||||
func Test_eow_with_optional()
|
|
||||||
let expected = ['abc def', 'abc', 'def', '', '', '', '', '', '', '']
|
|
||||||
for re in range(0, 2)
|
|
||||||
exe 'set re=' . re
|
|
||||||
let actual = matchlist('abc def', '\(abc\>\)\?\s*\(def\)')
|
|
||||||
call assert_equal(expected, actual)
|
|
||||||
endfor
|
|
||||||
endfunc
|
|
||||||
|
|
||||||
func Test_reversed_range()
|
func Test_reversed_range()
|
||||||
for re in range(0, 2)
|
for re in range(0, 2)
|
||||||
exe 'set re=' . re
|
exe 'set re=' . re
|
||||||
|
Reference in New Issue
Block a user