vim-patch:9.1.1005: completion text is highlighted even with no pattern found (#31973)

Problem:  completion text is highlighted even with no pattern found
Solution: use ins_compl_leader_len() instead of checking
          compl_leader.length (glepnir)

closes: vim/vim#16422

9fddb8ae77

Co-authored-by: glepnir <glephunter@gmail.com>
This commit is contained in:
zeertzjq 2025-01-12 08:04:25 +08:00 committed by GitHub
parent 88dca6a835
commit 37316fbac6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 18 additions and 2 deletions

View File

@ -970,7 +970,7 @@ int ins_compl_col_range_attr(int col)
return -1; return -1;
} }
if (col >= (compl_col + (int)compl_leader.size) && col < compl_ins_end_col) { if (col >= (compl_col + (int)ins_compl_leader_len()) && col < compl_ins_end_col) {
return syn_name2attr("ComplMatchIns"); return syn_name2attr("ComplMatchIns");
} }

View File

@ -5885,7 +5885,16 @@ describe('builtin popupmenu', function()
{1:~ }|*17 {1:~ }|*17
{2:-- }{5:match 1 of 3} | {2:-- }{5:match 1 of 3} |
]]) ]])
feed('<Esc>') feed('<C-E><Esc>')
command('set cot-=fuzzy')
feed('Sf<C-N>')
screen:expect([[
{10:f^ }|
{1:~ }|*18
{2:-- }{6:Pattern not found} |
]])
feed('<C-E><Esc>')
end) end)
end end
end end

View File

@ -1830,6 +1830,13 @@ func Test_pum_matchins_highlight_combine()
call term_sendkeys(buf, "S\<C-X>\<C-O>f\<C-N>") call term_sendkeys(buf, "S\<C-X>\<C-O>f\<C-N>")
call VerifyScreenDump(buf, 'Test_pum_matchins_combine_08', {}) call VerifyScreenDump(buf, 'Test_pum_matchins_combine_08', {})
call term_sendkeys(buf, "\<C-E>\<Esc>") call term_sendkeys(buf, "\<C-E>\<Esc>")
call TermWait(buf)
call term_sendkeys(buf, ":set cot-=fuzzy\<CR>")
call TermWait(buf)
call term_sendkeys(buf, "Sf\<C-N>")
call VerifyScreenDump(buf, 'Test_pum_matchins_combine_09', {})
call term_sendkeys(buf, "\<C-E>\<Esc>")
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
endfunc endfunc