mirror of
https://github.com/neovim/neovim
synced 2025-07-15 16:51:49 +00:00
vim-patch:9.1.1526: completion: search completion match may differ in case
Problem: completion: search completion match may differ in case
(techntools)
Solution: add "exacttext" to 'wildoptions' value (Girish Palya)
This flag does the following:
exacttext
When this flag is present, search pattern completion
(e.g., in |/|, |?|, |:s|, |:g|, |:v|, and |:vim|)
shows exact buffer text as menu items, without
preserving regex artifacts like position
anchors (e.g., |/\<|). This provides more intuitive
menu items that match the actual buffer text. However,
searches may be less accurate since the pattern is not
preserved exactly.
By default, Vim preserves the typed pattern (with
anchors) and appends the matched word. This preserves
search correctness, especially when using regular
expressions or with 'smartcase' enabled. However, the
case of the appended matched word may not exactly
match the case of the word in the buffer.
fixes: vim/vim#17654
closes: vim/vim#17667
93c2d5bf7f
Co-authored-by: Girish Palya <girishji@gmail.com>
This commit is contained in:
@ -4499,6 +4499,7 @@ func Test_search_complete()
|
||||
" Match case correctly
|
||||
%d
|
||||
call setline(1, ["foobar", "Foobar", "fooBAr", "FooBARR"])
|
||||
|
||||
call feedkeys("gg/f\<tab>\<f9>", 'tx')
|
||||
call assert_equal(['fooBAr', 'foobar'], g:compl_info.matches)
|
||||
call feedkeys("gg/Fo\<tab>\<f9>", 'tx')
|
||||
@ -4507,6 +4508,7 @@ func Test_search_complete()
|
||||
call assert_equal({}, g:compl_info)
|
||||
call feedkeys("gg/\\cFo\<tab>\<f9>", 'tx')
|
||||
call assert_equal(['\cFoobar', '\cFooBAr', '\cFooBARR'], g:compl_info.matches)
|
||||
|
||||
set ignorecase
|
||||
call feedkeys("gg/f\<tab>\<f9>", 'tx')
|
||||
call assert_equal(['foobar', 'fooBAr', 'fooBARR'], g:compl_info.matches)
|
||||
@ -4516,6 +4518,7 @@ func Test_search_complete()
|
||||
call assert_equal(['FOobar', 'FOoBAr', 'FOoBARR'], g:compl_info.matches)
|
||||
call feedkeys("gg/\\Cfo\<tab>\<f9>", 'tx')
|
||||
call assert_equal(['\CfooBAr', '\Cfoobar'], g:compl_info.matches)
|
||||
|
||||
set smartcase
|
||||
call feedkeys("gg/f\<tab>\<f9>", 'tx')
|
||||
call assert_equal(['foobar', 'fooBAr', 'foobarr'], g:compl_info.matches)
|
||||
@ -4523,16 +4526,42 @@ func Test_search_complete()
|
||||
call assert_equal(['Foobar', 'FooBARR'], g:compl_info.matches)
|
||||
call feedkeys("gg/FO\<tab>\<f9>", 'tx')
|
||||
call assert_equal({}, g:compl_info)
|
||||
call feedkeys("gg/foob\<tab>\<f9>", 'tx')
|
||||
call assert_equal(['foobar', 'foobarr'], g:compl_info.matches)
|
||||
call feedkeys("gg/\\Cfo\<tab>\<f9>", 'tx')
|
||||
call assert_equal(['\CfooBAr', '\Cfoobar'], g:compl_info.matches)
|
||||
call feedkeys("gg/\\cFo\<tab>\<f9>", 'tx')
|
||||
call assert_equal(['\cFoobar', '\cFooBAr', '\cFooBARR'], g:compl_info.matches)
|
||||
|
||||
set wildoptions+=exacttext ignorecase& smartcase&
|
||||
call feedkeys("gg/F\<tab>\<f9>", 'tx')
|
||||
call assert_equal(['Foobar', 'FooBARR'], g:compl_info.matches)
|
||||
call feedkeys("gg/foob\<tab>\<f9>", 'tx')
|
||||
call assert_equal([], g:compl_info.matches)
|
||||
call feedkeys("gg/r\\n.\<tab>\<f9>", 'tx')
|
||||
call assert_equal(['r\nFoobar', 'r\nfooBAr', 'r\nFooBARR'], g:compl_info.matches)
|
||||
|
||||
set ignorecase
|
||||
call feedkeys("gg/F\<tab>\<f9>", 'tx')
|
||||
call assert_equal(['Foobar', 'fooBAr', 'FooBARR', 'foobar'], g:compl_info.matches)
|
||||
call feedkeys("gg/R\\n.\<tab>\<f9>", 'tx')
|
||||
call assert_equal(['r\nFoobar', 'r\nfooBAr', 'r\nFooBARR'], g:compl_info.matches)
|
||||
|
||||
set smartcase
|
||||
call feedkeys("gg/f\<tab>\<f9>", 'tx')
|
||||
call assert_equal(['Foobar', 'fooBAr', 'FooBARR', 'foobar'], g:compl_info.matches)
|
||||
call feedkeys("gg/foob\<tab>\<f9>", 'tx')
|
||||
call assert_equal(['Foobar', 'fooBAr', 'FooBARR', 'foobar'], g:compl_info.matches)
|
||||
call feedkeys("gg/R\\n.\<tab>\<f9>", 'tx')
|
||||
call assert_equal({}, g:compl_info)
|
||||
call feedkeys("gg/r\\n.*\\n\<tab>\<f9>", 'tx')
|
||||
call assert_equal(['r\nFoobar\nfooBAr', 'r\nfooBAr\nFooBARR'], g:compl_info.matches)
|
||||
|
||||
bw!
|
||||
call Ntest_override("char_avail", 0)
|
||||
delfunc GetComplInfo
|
||||
unlet! g:compl_info
|
||||
set wildcharm=0 incsearch& ignorecase& smartcase&
|
||||
set wildcharm=0 incsearch& ignorecase& smartcase& wildoptions&
|
||||
endfunc
|
||||
|
||||
func Test_search_wildmenu_screendump()
|
||||
|
Reference in New Issue
Block a user