neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit 5f527f24f0ea89e9071e065530cbed449507df5c
parent d56ba71af11c9048c9085e4f66a47947770bdb29
Author: Mathias Fussenegger <f.mathias@zignar.net>
Date:   Sun, 19 Jan 2025 21:49:02 +0100

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.

Diffstat:
Mruntime/lua/vim/lsp/completion.lua | 3+++
Mtest/functional/plugin/lsp/completion_spec.lua | 11++++++++---
2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/runtime/lua/vim/lsp/completion.lua b/runtime/lua/vim/lsp/completion.lua @@ -231,6 +231,9 @@ end ---@param prefix string ---@return boolean local function match_item_by_value(value, prefix) + if prefix == '' then + return true + end if vim.o.completeopt:find('fuzzy') ~= nil then return next(vim.fn.matchfuzzy({ value }, prefix)) ~= nil end diff --git a/test/functional/plugin/lsp/completion_spec.lua b/test/functional/plugin/lsp/completion_spec.lua @@ -239,13 +239,18 @@ describe('vim.lsp.completion: item conversion', function() }, }, } - local expected = { + assert_completion_matches('<mo', items, { { abbr = 'module', word = '<module', }, - } - assert_completion_matches('<mo', items, expected) + }) + assert_completion_matches('', items, { + { + abbr = 'module', + word = 'module', + }, + }) end) it('fuzzy matches on label when filterText is missing', function()