mirror of
https://github.com/neovim/neovim.git
synced 2025-12-15 19:05:40 +00:00
fix(lsp): use filterText as word if textEdit/label doesn't match
Problem:
With language servers like lemminx, completing xml tags like `<mo` first
shows the right candidates (`modules`) but after typing `d` the
candidates disappear.
This is because the server returns:
[...]
filterText = "<module",
label = "module",
textEdit = {
newText = "<module>$1</module>$0",
Which resulted in `module` being used as `word`, and `module` doesn't
match the prefix `<mo`. Typing `d` causes the `complete()` filtering
mechanism to kick in and remove the entry.
Solution:
Use `<module` from the `filterText` as `word` if the textEdit/label
heuristic doesn't match.
This commit is contained in:
committed by
Mathias Fußenegger
parent
3530182ba4
commit
b9e6fa7ec8
@@ -216,6 +216,38 @@ describe('vim.lsp.completion: item conversion', function()
|
||||
})
|
||||
end)
|
||||
|
||||
it('uses filterText as word if label/newText would not match', function()
|
||||
local items = {
|
||||
{
|
||||
filterText = '<module',
|
||||
insertTextFormat = 2,
|
||||
kind = 10,
|
||||
label = 'module',
|
||||
sortText = 'module',
|
||||
textEdit = {
|
||||
newText = '<module>$1</module>$0',
|
||||
range = {
|
||||
start = {
|
||||
character = 0,
|
||||
line = 0,
|
||||
},
|
||||
['end'] = {
|
||||
character = 0,
|
||||
line = 0,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
local expected = {
|
||||
{
|
||||
abbr = 'module',
|
||||
word = '<module',
|
||||
},
|
||||
}
|
||||
assert_completion_matches('<mo', items, expected)
|
||||
end)
|
||||
|
||||
it('fuzzy matches on label when filterText is missing', function()
|
||||
assert_completion_matches('fo', {
|
||||
{ label = 'foo' },
|
||||
|
||||
Reference in New Issue
Block a user