mirror of
https://github.com/neovim/neovim.git
synced 2025-10-01 23:48:32 +00:00
fix(lsp): treat 2-triggers-at-once as "last char wins" #35435
Problem:
If there are 2 language servers with different trigger chars (`-` and
`>`), and a keymap inputs both simultaneously (`->`), then `>` doesn't
trigger. We get completion items from server1 only.
This happens because the `completion_timer` for the `-` trigger is still
pending.
Solution:
If the next character arrived enough quickly (< 25 ms), replace the
existing deferred autotrigger with a new one that matches this later
character.
(cherry picked from commit e69b81ad94
)
This commit is contained in:

committed by
github-actions[bot]
![github-actions[bot]](/assets/img/avatar_default.png)
parent
eb4837206a
commit
556d8d0002
@@ -1037,6 +1037,34 @@ describe('vim.lsp.completion: protocol', function()
|
||||
end)
|
||||
end)
|
||||
|
||||
it('treats 2-triggers-at-once as "last char wins"', function()
|
||||
local results1 = {
|
||||
isIncomplete = false,
|
||||
items = {
|
||||
{
|
||||
label = 'first',
|
||||
},
|
||||
},
|
||||
}
|
||||
create_server('dummy1', results1, { trigger_chars = { '-' } })
|
||||
local results2 = {
|
||||
isIncomplete = false,
|
||||
items = {
|
||||
{
|
||||
label = 'second',
|
||||
},
|
||||
},
|
||||
}
|
||||
create_server('dummy2', results2, { trigger_chars = { '>' } })
|
||||
|
||||
feed('i->')
|
||||
|
||||
assert_matches(function(matches)
|
||||
eq(1, #matches)
|
||||
eq('second', matches[1].word)
|
||||
end)
|
||||
end)
|
||||
|
||||
it('executes commands', function()
|
||||
local completion_list = {
|
||||
isIncomplete = false,
|
||||
|
Reference in New Issue
Block a user