mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 19:38:20 +00:00
fix(lsp): don't use completion filterText if prefix is empty
Follow up to https://github.com/neovim/neovim/pull/32072 If there is no prefix (e.g. at the start of word boundary or a line), it always used the `filterText` because the `match` function always returned false.
This commit is contained in:

committed by
Mathias Fußenegger

parent
d56ba71af1
commit
5f527f24f0
@@ -231,6 +231,9 @@ end
|
|||||||
---@param prefix string
|
---@param prefix string
|
||||||
---@return boolean
|
---@return boolean
|
||||||
local function match_item_by_value(value, prefix)
|
local function match_item_by_value(value, prefix)
|
||||||
|
if prefix == '' then
|
||||||
|
return true
|
||||||
|
end
|
||||||
if vim.o.completeopt:find('fuzzy') ~= nil then
|
if vim.o.completeopt:find('fuzzy') ~= nil then
|
||||||
return next(vim.fn.matchfuzzy({ value }, prefix)) ~= nil
|
return next(vim.fn.matchfuzzy({ value }, prefix)) ~= nil
|
||||||
end
|
end
|
||||||
|
@@ -239,13 +239,18 @@ describe('vim.lsp.completion: item conversion', function()
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
local expected = {
|
assert_completion_matches('<mo', items, {
|
||||||
{
|
{
|
||||||
abbr = 'module',
|
abbr = 'module',
|
||||||
word = '<module',
|
word = '<module',
|
||||||
},
|
},
|
||||||
}
|
})
|
||||||
assert_completion_matches('<mo', items, expected)
|
assert_completion_matches('', items, {
|
||||||
|
{
|
||||||
|
abbr = 'module',
|
||||||
|
word = 'module',
|
||||||
|
},
|
||||||
|
})
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('fuzzy matches on label when filterText is missing', function()
|
it('fuzzy matches on label when filterText is missing', function()
|
||||||
|
Reference in New Issue
Block a user