mirror of
https://github.com/neovim/neovim.git
synced 2024-12-24 13:15:09 -07:00
fix(lsp): error in reset_timer on second detach #24117
Problem: On running `zig fmt` manually, the on_lines callback and the server both detach (for some reason), and both of them call `clear()`. This fixes it, otherwise the second one to detach has an error in `reset_timer` since the bufstate doesn't exist Solution: * exit early in clear if `bufstates[bufnr]` is nil * set bufstatte.enabled to true on reload instead of making bufstate nil
This commit is contained in:
parent
46e95909bf
commit
fa0a25dcb3
@ -144,6 +144,9 @@ end
|
||||
---@private
|
||||
local function clear(bufnr)
|
||||
bufnr = resolve_bufnr(bufnr)
|
||||
if not bufstates[bufnr] then
|
||||
return
|
||||
end
|
||||
reset_timer(bufnr)
|
||||
local bufstate = bufstates[bufnr]
|
||||
local client_lens = (bufstate or {}).client_hint or {}
|
||||
@ -184,7 +187,9 @@ function M.enable(bufnr)
|
||||
end,
|
||||
on_reload = function(_, cb_bufnr)
|
||||
clear(cb_bufnr)
|
||||
bufstates[cb_bufnr] = nil
|
||||
if bufstates[cb_bufnr] and bufstates[cb_bufnr].enabled then
|
||||
bufstates[cb_bufnr] = { enabled = true }
|
||||
end
|
||||
M.refresh({ bufnr = cb_bufnr })
|
||||
end,
|
||||
on_detach = function(_, cb_bufnr)
|
||||
|
Loading…
Reference in New Issue
Block a user