diff options
-rw-r--r-- | lsp.c | 3 | ||||
-rw-r--r-- | lsp.h | 4 | ||||
-rw-r--r-- | main.c | 1 | ||||
-rw-r--r-- | ted.c | 6 |
4 files changed, 8 insertions, 6 deletions
@@ -407,7 +407,6 @@ static bool lsp_send(LSP *lsp) { quit = true; } } - lsp->died = true; free(messages); return quit; @@ -428,6 +427,8 @@ static int lsp_communication_thread(void *data) { break; } + lsp->exited = true; + if (!lsp->process) { // process already exited return 0; @@ -559,8 +559,8 @@ typedef struct LSP { // (when the initialize response is received) _Atomic bool initialized; // has the LSP server exited? - // thread-safety: only set to false once when the process dies - _Atomic bool died; + // thread-safety: atomic + _Atomic bool exited; // thread-safety: only set once in lsp_create. char *command; // this is set in lsp_create, then later set to NULL when we send over the configuration (after the initialized notification). @@ -1,6 +1,5 @@ /* @TODO: -- test that signature help requests and hover requests are cancelled - don't let 0 be a valid LSPDocumentID - TESTING: check all IDE features with different servers - run everything through valgrind ideally with leak checking @@ -151,7 +151,7 @@ LSP *ted_get_lsp_by_id(Ted *ted, LSPID id) { for (int i = 0; ted->lsps[i]; ++i) { LSP *lsp = ted->lsps[i]; if (lsp->id == id) - return lsp->died ? NULL : lsp; + return lsp->exited ? NULL : lsp; } return NULL; } @@ -173,8 +173,10 @@ LSP *ted_get_lsp(Ted *ted, const char *path, Language language) { // if the server supports workspaceFolders. return NULL; } - if (lsp->died) + if (lsp_covers_path(lsp, path) && lsp->exited) { + // this server died. give up. return NULL; + } // check if root matches up or if we can add a workspace folder char *root = ted_get_root_dir_of(ted, path); |