aboutsummaryrefslogtreecommitdiff
path: root/test/functional/plugin/lsp/completion_spec.lua
diff options
context:
space:
mode:
authorMathias Fußenegger <mfussenegger@users.noreply.github.com>2024-06-27 12:20:00 +0200
committerGitHub <noreply@github.com>2024-06-27 12:20:00 +0200
commit724d1110b1e4699a34f489e9cdb2d25098746499 (patch)
tree84dc431d609c9e3f7342498b73e88658f0477c61 /test/functional/plugin/lsp/completion_spec.lua
parentfc9b70826ec88ca2e6c0624c522b872e87aa7ac1 (diff)
downloadrneovim-724d1110b1e4699a34f489e9cdb2d25098746499.tar.gz
rneovim-724d1110b1e4699a34f489e9cdb2d25098746499.tar.bz2
rneovim-724d1110b1e4699a34f489e9cdb2d25098746499.zip
fix(lsp): pre-filter matches on label if filterText is missing (#29491)
Although the built-in pum completion mechanism will filter anyway on the next input it is odd if the initial popup shows entries which don't match the current prefix. Using fuzzy match on the label/prefix is compatible with `completeopt+=fuzzy` and also doesn't seem to break postfix snippet cases Closes https://github.com/neovim/neovim/issues/29287
Diffstat (limited to 'test/functional/plugin/lsp/completion_spec.lua')
-rw-r--r--test/functional/plugin/lsp/completion_spec.lua21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/functional/plugin/lsp/completion_spec.lua b/test/functional/plugin/lsp/completion_spec.lua
index 1b56d1740a..bc10c0c937 100644
--- a/test/functional/plugin/lsp/completion_spec.lua
+++ b/test/functional/plugin/lsp/completion_spec.lua
@@ -141,6 +141,27 @@ describe('vim.lsp.completion: item conversion', function()
eq(expected, result)
end)
+ it('filters on label if filterText is missing', function()
+ local completion_list = {
+ { label = 'foo' },
+ { label = 'bar' },
+ }
+ local result = complete('fo|', completion_list)
+ local expected = {
+ {
+ abbr = 'foo',
+ word = 'foo',
+ },
+ }
+ result = vim.tbl_map(function(x)
+ return {
+ abbr = x.abbr,
+ word = x.word,
+ }
+ end, result.items)
+ eq(expected, result)
+ end)
+
it('trims trailing newline or tab from textEdit', function()
local range0 = {
start = { line = 0, character = 0 },