vim-patch:8.0.0689: ~ character not escaped when extending search pattern

Problem:    The ~ character is not escaped when adding to the search pattern
            with CTRL-L. (Ramel Eshed)
Solution:   Escape the character. (Christian Brabandt)

a693d0584b
This commit is contained in:
Justin M. Keyes 2018-02-01 23:46:04 +01:00
parent c8356e1151
commit ca24ad0b95
2 changed files with 22 additions and 1 deletions

View File

@ -1549,7 +1549,7 @@ static int command_line_handle_key(CommandLineState *s)
}
if (s->c != NUL) {
if (s->c == s->firstc
|| vim_strchr((char_u *)(p_magic ? "\\^$.*[" : "\\^$"), s->c)
|| vim_strchr((char_u *)(p_magic ? "\\~^$.*[" : "\\^$"), s->c)
!= NULL) {
// put a backslash before special characters
stuffcharReadbuff(s->c);

View File

@ -306,3 +306,24 @@ func Test_searchc()
exe "norm 0t\u93cf"
bw!
endfunc
func Test_search_cmdline3()
throw 'skipped: Nvim does not support test_override()'
if !exists('+incsearch')
return
endif
" need to disable char_avail,
" so that expansion of commandline works
call test_override("char_avail", 1)
new
call setline(1, [' 1', ' 2 the~e', ' 3 the theother'])
set incsearch
1
" first match
call feedkeys("/the\<c-l>\<cr>", 'tx')
call assert_equal(' 2 the~e', getline('.'))
" clean up
set noincsearch
call test_override("char_avail", 0)
bw!
endfunc