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.
This commit is contained in:
v1nh1shungry
2025-10-01 21:56:56 +08:00
committed by GitHub
parent a053186aa7
commit 70460d557c

View File

@@ -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,