aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaehwang Jung <tomtomjhj@gmail.com>2025-01-02 17:33:16 +0900
committerLewis Russell <me@lewisr.dev>2025-01-02 10:23:06 +0000
commit9d9ee3476e6478850ce8822c85154f0c98570371 (patch)
tree05d37c5e24bfac34e69235248772730b7c643ca2
parentefe1732c6fd802ca8fdccc1f0a26be87427f1e70 (diff)
downloadrneovim-9d9ee3476e6478850ce8822c85154f0c98570371.tar.gz
rneovim-9d9ee3476e6478850ce8822c85154f0c98570371.tar.bz2
rneovim-9d9ee3476e6478850ce8822c85154f0c98570371.zip
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.
-rw-r--r--runtime/lua/vim/lsp/_watchfiles.lua1
-rw-r--r--runtime/lua/vim/lsp/client.lua3
2 files changed, 3 insertions, 1 deletions
diff --git a/runtime/lua/vim/lsp/_watchfiles.lua b/runtime/lua/vim/lsp/_watchfiles.lua
index 248969885c..4711b3cc9b 100644
--- 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
index d51a45b473..5d11312c77 100644
--- 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