mirror of
https://github.com/neovim/neovim.git
synced 2026-07-14 13:20:35 +00:00
fix(lsp): fallback to filterText for non-matching PlainText items #39695
Problem: PlainText completion items used `textEdit.newText` or `insertText` as the completion word even when they did not match the typed prefix. This could break popup completion behavior like 'completeopt+=longest'. Solution: Fall back to `filterText` when `newText` or `insertText` does not match the typed prefix.
This commit is contained in:
@@ -211,8 +211,15 @@ local function get_completion_word(item, prefix, match)
|
||||
elseif item.textEdit then
|
||||
local word = item.textEdit.newText
|
||||
word = string.gsub(word, '\r\n?', '\n')
|
||||
return word:match('([^\n]*)') or word
|
||||
word = word:match('([^\n]*)') or word
|
||||
if item.filterText and not match(word, prefix) then
|
||||
return item.filterText
|
||||
end
|
||||
return word
|
||||
elseif item.insertText and item.insertText ~= '' then
|
||||
if item.filterText and not match(item.insertText, prefix) then
|
||||
return item.filterText
|
||||
end
|
||||
return item.insertText
|
||||
end
|
||||
return item.label
|
||||
|
||||
Reference in New Issue
Block a user