aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim
diff options
context:
space:
mode:
authorglepnir <glephunter@gmail.com>2026-05-18 17:25:41 +0800
committerGitHub <noreply@github.com>2026-05-18 05:25:41 -0400
commit3ffe29d679b2a4aee5a2f6fd9eee4845c4fef0e5 (patch)
tree85e2563c7988376565a1a69c5cf2eaf91d1f01fe /runtime/lua/vim
parentd7164eced6d6dc363eaee0c47538c5ff6552e3ba (diff)
downloadrneovim-3ffe29d679b2a4aee5a2f6fd9eee4845c4fef0e5.tar.gz
rneovim-3ffe29d679b2a4aee5a2f6fd9eee4845c4fef0e5.tar.bz2
rneovim-3ffe29d679b2a4aee5a2f6fd9eee4845c4fef0e5.zip
fix(lsp): preserve trigger chars on completion #39850
Problem: After 767fbd8, typing trigger chars would open completion but the chars were removed. Solution: Use filterText fallback so selected item respects typed trigger chars.
Diffstat (limited to 'runtime/lua/vim')
-rw-r--r--runtime/lua/vim/lsp/completion.lua23
1 files changed, 10 insertions, 13 deletions
diff --git a/runtime/lua/vim/lsp/completion.lua b/runtime/lua/vim/lsp/completion.lua
index 4f6c9022ea..a096d778b4 100644
--- a/runtime/lua/vim/lsp/completion.lua
+++ b/runtime/lua/vim/lsp/completion.lua
@@ -168,6 +168,13 @@ local function apply_snippet(item)
end
end
+local function fallback_filtertext(item, word, prefix, match)
+ if item.filterText and not match(word, prefix) and match(item.filterText, prefix) then
+ return item.filterText
+ end
+ return word
+end
+
--- Returns text that should be inserted when a selecting completion item. The
--- precedence is as follows: textEdit.newText > insertText > label
---
@@ -200,11 +207,7 @@ local function get_completion_word(item, prefix, match)
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
- return word
- end
+ return fallback_filtertext(item, word, prefix, match)
else
return item.label
end
@@ -212,15 +215,9 @@ local function get_completion_word(item, prefix, match)
local word = item.textEdit.newText
word = string.gsub(word, '\r\n?', '\n')
word = word:match('([^\n]*)') or word
- if item.filterText and not match(word, prefix) then
- return item.filterText
- end
- return word
+ return fallback_filtertext(item, word, prefix, match)
elseif item.insertText and item.insertText ~= '' then
- if item.filterText and not match(item.insertText, prefix) then
- return item.filterText
- end
- return item.insertText
+ return fallback_filtertext(item, item.insertText, prefix, match)
end
return item.label
end