diff options
| author | glepnir <glephunter@gmail.com> | 2026-03-23 23:02:30 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-23 11:02:30 -0400 |
| commit | f2d0b06ecbb50541db748cd7974a24816b609dd3 (patch) | |
| tree | e796749a7c8abecc10496bff05f597fb9dd8e327 /runtime/lua/vim/lsp/completion.lua | |
| parent | e2afa762c86833d49faaba1574ee109c82e3c85c (diff) | |
| download | rneovim-f2d0b06ecbb50541db748cd7974a24816b609dd3.tar.gz rneovim-f2d0b06ecbb50541db748cd7974a24816b609dd3.tar.bz2 rneovim-f2d0b06ecbb50541db748cd7974a24816b609dd3.zip | |
fix(lsp): completion word includes leading space from label #38435
Problem: clangd prepends a space/bullet indicator to label. With
labelDetailsSupport enabled, the signature moves to labelDetails,
making label shorter. This flips the length comparison in
get_completion_word, causing it to use item.label directly and
insert the indicator into the buffer.
Solution: only prefer filterText over label when label starts with non-keyword
character in get_completion_word fallback branch.
Diffstat (limited to 'runtime/lua/vim/lsp/completion.lua')
| -rw-r--r-- | runtime/lua/vim/lsp/completion.lua | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/runtime/lua/vim/lsp/completion.lua b/runtime/lua/vim/lsp/completion.lua index 4cce188798..7795f42645 100644 --- a/runtime/lua/vim/lsp/completion.lua +++ b/runtime/lua/vim/lsp/completion.lua @@ -195,7 +195,11 @@ local function get_completion_word(item, prefix, match) -- -- Typing `i` would remove the candidate because newText starts with `t`. local text = parse_snippet(item.insertText or item.textEdit.newText) - local word = #text < #item.label and vim.fn.matchstr(text, '\\k*') or item.label + local word = #text < #item.label and vim.fn.matchstr(text, '\\k*') + or ( + item.filterText and vim.fn.match(item.label, '^\\k') == -1 and item.filterText + or item.label + ) if item.filterText and not match(word, prefix) then return item.filterText else |