summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ide-hover.c5
-rw-r--r--lsp.c35
-rw-r--r--test/lsp/python/test.py10
3 files changed, 43 insertions, 7 deletions
diff --git a/ide-hover.c b/ide-hover.c
index f99c2e7..2be04ca 100644
--- a/ide-hover.c
+++ b/ide-hover.c
@@ -46,7 +46,10 @@ void hover_process_lsp_response(Ted *ted, LSPResponse *response) {
TextBuffer *buffer=0;
LSPDocumentPosition pos={0};
LSP *lsp=0;
- get_hover_position(ted, &pos, &buffer, &lsp);
+ if (!get_hover_position(ted, &pos, &buffer, &lsp)) {
+ free(hover->text); hover->text = NULL;
+ return;
+ }
if (hover->text // we already have hover text
&& (
diff --git a/lsp.c b/lsp.c
index 1cbe9e6..34f56ae 100644
--- a/lsp.c
+++ b/lsp.c
@@ -492,8 +492,8 @@ LSP *lsp_create(const char *root_dir, const char *command, const char *configura
lsp->log = log;
#if DEBUG
- printf("Starting up LSP %p `%s` in %s\n",
- (void *)lsp, command, root_dir);
+ printf("Starting up LSP %p (ID %u) `%s` in %s\n",
+ (void *)lsp, (unsigned)lsp->id, command, root_dir);
#endif
str_hash_table_create(&lsp->document_ids, sizeof(u32));
@@ -657,8 +657,31 @@ bool lsp_covers_path(LSP *lsp, const char *path) {
void lsp_cancel_request(LSP *lsp, LSPRequestID id) {
if (!id) return;
if (!lsp) return;
-
- LSPRequest request = {.type = LSP_REQUEST_CANCEL};
- request.data.cancel.id = id;
- lsp_send_request(lsp, &request);
+ bool sent = false;
+ SDL_LockMutex(lsp->messages_mutex);
+ for (u32 i = 0; i < arr_len(lsp->requests_sent); ++i) {
+ LSPRequest *req = &lsp->requests_sent[i];
+ if (req->id == id) {
+ // we sent this request but haven't received a response
+ sent = true;
+ arr_remove(lsp->requests_sent, i);
+ break;
+ }
+ }
+
+ for (u32 i = 0; i < arr_len(lsp->messages_client2server); ++i) {
+ LSPMessage *message = &lsp->messages_client2server[i];
+ if (message->type == LSP_REQUEST && message->u.request.id == id) {
+ // we haven't sent this request yet
+ arr_remove(lsp->messages_client2server, i);
+ break;
+ }
+
+ }
+ SDL_UnlockMutex(lsp->messages_mutex);
+ if (sent) {
+ LSPRequest request = {.type = LSP_REQUEST_CANCEL};
+ request.data.cancel.id = id;
+ lsp_send_request(lsp, &request);
+ }
}
diff --git a/test/lsp/python/test.py b/test/lsp/python/test.py
new file mode 100644
index 0000000..7b23309
--- /dev/null
+++ b/test/lsp/python/test.py
@@ -0,0 +1,10 @@
+def funciton() -> str:
+ ''' this function does things '''
+ print('here')
+ print('there')
+ return 'something something'
+
+funciton()
+funciton()
+funciton()
+funciton()