fix(ui): exclude unfocusable windows from 'complete' "w" completion

Problem:  As in f85bc41, assume unfocusable windows to be UI windows
          whose buffer content is unexpectedly included in 'complete'
          "w" completion.
Solution: Exclude unfocusable windows when looping over windows.
(cherry picked from commit d01b2611a6)
This commit is contained in:
Luuk van Baal
2025-04-24 16:05:40 +02:00
committed by github-actions[bot]
parent 66953b16a2
commit 9909580df2
3 changed files with 27 additions and 4 deletions

View File

@@ -1351,4 +1351,26 @@ describe('completion', function()
eq('completeopt option does not include popup', api.nvim_get_var('err_msg'))
end)
end)
it([[does not include buffer from non-focusable window for 'complete' "w"]], function()
local buf = api.nvim_create_buf(false, true)
local cfg = { focusable = false, relative = 'win', bufpos = { 1, 0 }, width = 1, height = 1 }
local win = api.nvim_open_win(buf, false, cfg)
api.nvim_buf_set_lines(buf, 0, -1, false, { 'foo' })
feed('i<C-N>')
screen:expect([[
^ |
{4:f}{1: }|
{1:~ }|*5
{5:-- Keyword completion (^N^P) }{9:Pattern not found} |
]])
api.nvim_win_set_config(win, { focusable = true })
feed('<Esc>i<C-N>')
screen:expect([[
foo^ |
{4:f}{1: }|
{1:~ }|*5
{5:-- Keyword completion (^N^P) The only match} |
]])
end)
end)