From f97cd39cabc942763188527c0f4808a56928ba53 Mon Sep 17 00:00:00 2001 From: Yingchi Long Date: Fri, 19 Apr 2024 10:47:04 +0800 Subject: [PATCH] nixd: remove NixTU after 'didClose' --- nixd/include/nixd/Controller/Controller.h | 2 +- nixd/lib/Controller/Support.cpp | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/nixd/include/nixd/Controller/Controller.h b/nixd/include/nixd/Controller/Controller.h index cfad6331d..1f4ac3611 100644 --- a/nixd/include/nixd/Controller/Controller.h +++ b/nixd/include/nixd/Controller/Controller.h @@ -140,7 +140,7 @@ class Controller : public lspserver::LSPServer { void actOnDocumentAdd(lspserver::PathRef File, std::optional Version); - void removeDocument(lspserver::PathRef File) { Store.removeDraft(File); } + void removeDocument(lspserver::PathRef File); void onInitialize(const lspserver::InitializeParams &Params, lspserver::Callback Reply); diff --git a/nixd/lib/Controller/Support.cpp b/nixd/lib/Controller/Support.cpp index a3a303c98..8c90c8fb0 100644 --- a/nixd/lib/Controller/Support.cpp +++ b/nixd/lib/Controller/Support.cpp @@ -27,7 +27,13 @@ std::string getShmName(std::string_view File) { } // namespace -namespace nixd { +void Controller::removeDocument(lspserver::PathRef File) { + Store.removeDraft(File); + { + std::lock_guard _(TUsLock); + TUs.erase(File); + } +} void Controller::actOnDocumentAdd(PathRef File, std::optional Version) { @@ -167,5 +173,3 @@ Controller::Controller(std::unique_ptr In, EndWorkDoneProgress = mkOutNotifiction>("$/progress"); } - -} // namespace nixd