aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp/completion.lua
diff options
context:
space:
mode:
authorMathias Fußenegger <mfussenegger@users.noreply.github.com>2024-06-02 09:54:15 +0200
committerGitHub <noreply@github.com>2024-06-02 09:54:15 +0200
commit19be3d26830ced203631045f2f622e75e6d857a7 (patch)
tree2b68c87663e010eaf6d0369ebb20932cb9d18991 /runtime/lua/vim/lsp/completion.lua
parent24cb9ba6d32918beaba5a2109f5f8d8009cd097d (diff)
downloadrneovim-19be3d26830ced203631045f2f622e75e6d857a7.tar.gz
rneovim-19be3d26830ced203631045f2f622e75e6d857a7.tar.bz2
rneovim-19be3d26830ced203631045f2f622e75e6d857a7.zip
fix(lsp): trim trailing whitespace from completion words (#29122)
the `complete()` mechanism doesn't play nicely with trailing newlines or tabs. A newline causes it to insert a null character, showing up as `^@`.
Diffstat (limited to 'runtime/lua/vim/lsp/completion.lua')
-rw-r--r--runtime/lua/vim/lsp/completion.lua3
1 files changed, 2 insertions, 1 deletions
diff --git a/runtime/lua/vim/lsp/completion.lua b/runtime/lua/vim/lsp/completion.lua
index b77bf3e3c2..f8e17ae2f0 100644
--- a/runtime/lua/vim/lsp/completion.lua
+++ b/runtime/lua/vim/lsp/completion.lua
@@ -153,7 +153,8 @@ local function get_completion_word(item)
return item.label
end
elseif item.textEdit then
- return item.textEdit.newText
+ local word = item.textEdit.newText
+ return word:match('^(%S*)') or word
elseif item.insertText and item.insertText ~= '' then
return item.insertText
end