commit 70460d557c510149678f525efddc158709a79839
parent a053186aa71d2c9fc108fd84cfce5f1a15004c05
Author: v1nh1shungry <v1nh1shungry@outlook.com>
Date: Wed, 1 Oct 2025 21:56:56 +0800
fix(lsp): scope inline_completion autocmds to buffer (#35965)
Problem:
Autocmds in inline_completion Completor are not scoped to specific
buffers. When multiple buffers have inline completion enabled, events
(InsertEnter, CursorMovedI, TextChangedP, InsertLeave) in any buffer
trigger callbacks for all Completor instances, causing incorrect
behavior across buffers.
Solution:
Add `buffer = bufnr` parameter to nvim_create_autocmd() calls to make
them buffer-local. Each Completor instance now only responds to events
in its own buffer.
Diffstat:
1 file changed, 2 insertions(+), 0 deletions(-)
diff --git a/runtime/lua/vim/lsp/inline_completion.lua b/runtime/lua/vim/lsp/inline_completion.lua
@@ -76,12 +76,14 @@ function Completor:new(bufnr)
self.client_state = {}
api.nvim_create_autocmd({ 'InsertEnter', 'CursorMovedI', 'TextChangedP' }, {
group = self.augroup,
+ buffer = bufnr,
callback = function()
self:automatic_request()
end,
})
api.nvim_create_autocmd({ 'InsertLeave' }, {
group = self.augroup,
+ buffer = bufnr,
callback = function()
self:abort()
end,