mirror of
https://github.com/neovim/neovim.git
synced 2025-10-26 12:27:24 +00:00
fix(lsp): do not detach from buffer if there are uninitialized clients (#29029)
Problem: if on_lines is called before the LSP is initialized, the buffer is detached. Solution: check for uninitialized clients before detaching.
This commit is contained in:
@@ -577,7 +577,8 @@ local function buf_attach(bufnr)
|
||||
api.nvim_buf_attach(bufnr, false, {
|
||||
on_lines = function(_, _, changedtick, firstline, lastline, new_lastline)
|
||||
if #lsp.get_clients({ bufnr = bufnr }) == 0 then
|
||||
return true -- detach
|
||||
-- detach if there are no clients
|
||||
return #lsp.get_clients({ bufnr = bufnr, _uninitialized = true }) == 0
|
||||
end
|
||||
util.buf_versions[bufnr] = changedtick
|
||||
changetracking.send_changes(bufnr, firstline, lastline, new_lastline)
|
||||
|
||||
Reference in New Issue
Block a user