From 7ed34444c62cc75954425f29c4f04149647fdb1c Mon Sep 17 00:00:00 2001 From: Supakorn 'Jamie' Rassameemasmuang Date: Sat, 20 Apr 2024 11:51:42 -0600 Subject: [PATCH] LSP: Add mutex to on change to ensure changes are not done concurrently. --- include/lspserv.h | 2 ++ src/lspserv.cc | 1 + 2 files changed, 3 insertions(+) diff --git a/include/lspserv.h b/include/lspserv.h index 286c75b6c..d4b22dbda 100644 --- a/include/lspserv.h +++ b/include/lspserv.h @@ -175,6 +175,8 @@ namespace AsymptoteLsp unique_ptr symmapContextsPtr; unique_ptr>> fileContentsPtr; std::string plainFile; + + std::mutex onChangeMutex; }; class TCPAsymptoteLSPServer : public lsp::TcpServer, public AsymptoteLspServer diff --git a/src/lspserv.cc b/src/lspserv.cc index 328cf9e47..df3aa11ac 100644 --- a/src/lspserv.cc +++ b/src/lspserv.cc @@ -317,6 +317,7 @@ std::string wslUnix2Dos(std::string const& unixPath) void AsymptoteLspServer::onChange(Notify_TextDocumentDidChange::notify& notify) { + std::lock_guard lk(onChangeMutex); logInfo("text change notification"); auto& fileChange = notify.params.contentChanges;