diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-12-04 09:46:26 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2022-12-04 10:07:05 +0800 |
commit | 9476dd2f923d9e5d86237836131f67024613308f (patch) | |
tree | 32295d58a80f90a2d3b1d66d9034c7bd2fc4a093 | |
parent | 3f1ee12d311fffe30936217c74ef0352bb7d97d9 (diff) | |
download | rneovim-9476dd2f923d9e5d86237836131f67024613308f.tar.gz rneovim-9476dd2f923d9e5d86237836131f67024613308f.tar.bz2 rneovim-9476dd2f923d9e5d86237836131f67024613308f.zip |
vim-patch:8.2.3292: underscore in very magic pattern causes a hang
Problem: Underscore in very magic pattern causes a hang. Pattern with \V
are case sensitive. (Yutao Yuan)
Solution: Adjust condition for magicness and advance pointer. (Christian
Brabandt, closes vim/vim#8707, closes vim/vim#8704, closes vim/vim#8705)
https://github.com/vim/vim/commit/bc67e5a0a494f5fc48e872d747371e31a782d171
Co-authored-by: Christian Brabandt <cb@256bit.org>
-rw-r--r-- | src/nvim/search.c | 4 | ||||
-rw-r--r-- | src/nvim/testdir/test_search.vim | 11 |
2 files changed, 14 insertions, 1 deletions
diff --git a/src/nvim/search.c b/src/nvim/search.c index 9814822f76..009e8b4e19 100644 --- a/src/nvim/search.c +++ b/src/nvim/search.c @@ -386,7 +386,7 @@ bool pat_has_uppercase(char_u *pat) return true; } p += l; - } else if (*p == '\\' && magic_val == MAGIC_ON) { + } else if (*p == '\\' && magic_val <= MAGIC_ON) { if (p[1] == '_' && p[2] != NUL) { // skip "\_X" p += 3; } else if (p[1] == '%' && p[2] != NUL) { // skip "\%X" @@ -399,6 +399,8 @@ bool pat_has_uppercase(char_u *pat) } else if ((*p == '%' || *p == '_') && magic_val == MAGIC_ALL) { if (p[1] != NUL) { // skip "_X" and %X p += 2; + } else { + p++; } } else if (mb_isupper(*p)) { return true; diff --git a/src/nvim/testdir/test_search.vim b/src/nvim/testdir/test_search.vim index 51e7064c94..a9cad3ed44 100644 --- a/src/nvim/testdir/test_search.vim +++ b/src/nvim/testdir/test_search.vim @@ -2048,6 +2048,17 @@ func Test_pattern_is_uppercase_smartcase() call assert_equal(['abc', 'ABC', 'Abc', ''], \ getline(1, '$')) + call setline(1, input) + call cursor(1,1) + " \Vabc should match everything + %s/\Vabc//g + call assert_equal(['', '', '', ''], getline(1, '$')) + + call setline(1, input + ['_abc']) + " _ matches normally + %s/\v_.*//g + call assert_equal(['abc', 'ABC', 'Abc', 'abC', ''], getline(1, '$')) + set smartcase& ignorecase& bw! endfunc |