summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2023-01-08 09:45:58 -0500
committerpommicket <pommicket@gmail.com>2023-01-08 09:45:58 -0500
commit2d2922637d08bb156cfdcbaaba00a974e6e7a8cf (patch)
tree09fe8a64402245bb3618595f3a10a2e6bbafe22e
parent498b670de076909452c0fd6bc4629aca8974d9f7 (diff)
make 0 not a valid document ID
-rw-r--r--lsp.c5
-rw-r--r--lsp.h2
-rw-r--r--main.c2
3 files changed, 6 insertions, 3 deletions
diff --git a/lsp.c b/lsp.c
index a7d7e2f..dde58d6 100644
--- a/lsp.c
+++ b/lsp.c
@@ -523,6 +523,11 @@ LSP *lsp_create(const char *root_dir, const char *command, const char *configura
lsp->quit_sem = SDL_CreateSemaphore(0);
lsp->error_mutex = SDL_CreateMutex();
lsp->messages_mutex = SDL_CreateMutex();
+
+ // document ID 0 is reserved
+ LSPDocumentID zero_id = lsp_document_id(lsp, "");
+ assert(zero_id == 0);
+
arr_add(lsp->workspace_folders, lsp_document_id(lsp, root_dir));
lsp->workspace_folders_mutex = SDL_CreateMutex();
diff --git a/lsp.h b/lsp.h
index 68e90e6..1e11180 100644
--- a/lsp.h
+++ b/lsp.h
@@ -8,7 +8,7 @@
#include "ds.h"
#include "os.h"
-// an ID specific to a path. 0 is a valid document ID, currently.
+// an ID specific to a path. a document's ID is never 0 (thanks to lsp_create).
typedef u32 LSPDocumentID;
// ID of an LSP server. a server's ID is never 0.
typedef u32 LSPID;
diff --git a/main.c b/main.c
index 32553da..8393da8 100644
--- a/main.c
+++ b/main.c
@@ -1,7 +1,5 @@
/*
@TODO:
-- don't let 0 be a valid LSPDocumentID
-- TESTING: check all IDE features with different servers
- run everything through valgrind ideally with leak checking
- some way of opening + closing all C files in directory for clangd
textDocument/references to work?