mirror of
https://github.com/neovim/neovim.git
synced 2025-09-23 11:38:31 +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.
This commit is contained in:
@@ -571,7 +571,10 @@ local function on_insert_char_pre(handle)
|
||||
|
||||
local char = api.nvim_get_vvar('char')
|
||||
local matched_clients = handle.triggers[char]
|
||||
if not completion_timer and matched_clients then
|
||||
-- Discard pending trigger char, complete the "latest" one.
|
||||
-- Can happen if a mapping inputs multiple trigger chars simultaneously.
|
||||
reset_timer()
|
||||
if matched_clients then
|
||||
completion_timer = assert(vim.uv.new_timer())
|
||||
completion_timer:start(25, 0, function()
|
||||
reset_timer()
|
||||
|
Reference in New Issue
Block a user