diff options
author | pommicket <pommicket@gmail.com> | 2022-12-24 12:29:51 -0500 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2022-12-24 12:29:51 -0500 |
commit | a68d59e180b8131197c6387a764a78403b06e069 (patch) | |
tree | 53d32414fda2a4631a8476e766dcda8c0833c208 | |
parent | e1b3296d7ecae1bf1620f53714ec3ba5b31709d4 (diff) |
fix ted_get_lsp problem
-rw-r--r-- | buffer.c | 23 | ||||
-rw-r--r-- | lsp.c | 4 | ||||
-rw-r--r-- | main.c | 1 | ||||
-rw-r--r-- | ted.c | 1 |
4 files changed, 15 insertions, 14 deletions
@@ -2207,19 +2207,20 @@ Status buffer_load_file(TextBuffer *buffer, char const *filename) { // can't write to this file; make the buffer view only. buffer->view_only = true; } + + LSP *lsp = buffer_lsp(buffer); + if (lsp) { + // send didOpen + LSPRequest request = {.type = LSP_REQUEST_DID_OPEN}; + LSPRequestDidOpen *open = &request.data.open; + open->file_contents = (char *)file_contents; + open->document = lsp_document_id(lsp, filename); + open->language = buffer_language(buffer); + lsp_send_request(lsp, &request); + file_contents = NULL; // don't free + } } - LSP *lsp = buffer_lsp(buffer); - if (lsp) { - // send didOpen - LSPRequest request = {.type = LSP_REQUEST_DID_OPEN}; - LSPRequestDidOpen *open = &request.data.open; - open->file_contents = (char *)file_contents; - open->document = lsp_document_id(lsp, filename); - open->language = buffer_language(buffer); - lsp_send_request(lsp, &request); - file_contents = NULL; // don't free - } } free(file_contents); @@ -296,8 +296,8 @@ LSP *lsp_create(const char *root_dir, Language language, const char *analyzer_co if (!lsp) return NULL; #if DEBUG - printf("Starting up LSP `%s` for language %s in %s\n", - analyzer_command, language_to_str(language), root_dir); + printf("Starting up LSP %p `%s` for language %s in %s\n", + (void *)lsp, analyzer_command, language_to_str(language), root_dir); #endif ProcessSettings settings = { @@ -1,6 +1,5 @@ /* @TODO: -- why arent we always sending didOpen? - make sure "save as" works - workspaceFolders support (so we don't need to start up multiple instances of rust-analyzer) - more LSP stuff: @@ -111,6 +111,7 @@ LSP *ted_get_lsp(Ted *ted, const char *path, Language language) { char *root_dir = settings_get_root_dir(settings, path); ted->lsps[i] = lsp_create(root_dir, language, settings->lsp); free(root_dir); + return ted->lsps[i]; } return NULL; |