neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit 9476dd2f923d9e5d86237836131f67024613308f
parent 3f1ee12d311fffe30936217c74ef0352bb7d97d9
Author: zeertzjq <zeertzjq@outlook.com>
Date:   Sun,  4 Dec 2022 09:46:26 +0800

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>

Diffstat:
Msrc/nvim/search.c | 4+++-
Msrc/nvim/testdir/test_search.vim | 11+++++++++++
2 files changed, 14 insertions(+), 1 deletion(-)

diff --git 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 @@ -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