commit 9d9ee3476e6478850ce8822c85154f0c98570371
parent efe1732c6fd802ca8fdccc1f0a26be87427f1e70
Author: Jaehwang Jung <tomtomjhj@gmail.com>
Date: Thu, 2 Jan 2025 17:33:16 +0900
fix(lsp): ensure watcher cancel
* Cancel watcher in the "force" case.
* Cancel watcher outside the async callback. It seems nvim doesn't wait
async jobs on quitting, leaving detached inotifywait processes.
* Clean up cancelling callbacks.
Diffstat:
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/runtime/lua/vim/lsp/_watchfiles.lua b/runtime/lua/vim/lsp/_watchfiles.lua
@@ -174,6 +174,7 @@ function M.cancel(client_id)
cancel()
end
end
+ cancels[client_id] = nil
end
return M
diff --git a/runtime/lua/vim/lsp/client.lua b/runtime/lua/vim/lsp/client.lua
@@ -805,6 +805,8 @@ function Client:stop(force)
return
end
+ vim.lsp._watchfiles.cancel(self.id)
+
if force or not self.initialized or self._graceful_shutdown_failed then
rpc.terminate()
return
@@ -819,7 +821,6 @@ function Client:stop(force)
rpc.terminate()
self._graceful_shutdown_failed = true
end
- vim.lsp._watchfiles.cancel(self.id)
end)
end