vim-patch:9.1.1520: completion: search completion doesn't handle 'smartcase' well (#34840)

Problem:  When using `/` or `?` in command-line mode with 'ignorecase' and
          'smartcase' enabled, the completion menu could show items that
          don't actually match any text in the buffer due to case mismatches

Solution: Instead of validating menu items only against the user-typed
          pattern, the new logic also checks whether the completed item
          matches actual buffer content. If needed, it retries the match
          using a lowercased version of the candidate, respecting
          smartcase semantics.

closes: vim/vim#17665

af22007784

Co-authored-by: Girish Palya <girishji@gmail.com>
This commit is contained in:
zeertzjq
2025-07-08 08:07:42 +08:00
committed by GitHub
parent ed8b022633
commit 27daeb0d68
2 changed files with 76 additions and 29 deletions

View File

@@ -4505,6 +4505,8 @@ 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/\\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)
@@ -4512,13 +4514,19 @@ func Test_search_complete()
call assert_equal(['Foobar', 'FooBAr', 'FooBARR'], g:compl_info.matches)
call feedkeys("gg/FO\<tab>\<f9>", 'tx')
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)
call assert_equal(['foobar', 'fooBAr', 'foobarr'], g:compl_info.matches)
call feedkeys("gg/Fo\<tab>\<f9>", 'tx')
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/\\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)
bw!
call Ntest_override("char_avail", 0)