diff options
author | pommicket <pommicket@gmail.com> | 2022-12-30 15:27:38 -0500 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2022-12-30 15:27:38 -0500 |
commit | d51f4ce90fc40bb6b1813e7716d1db40cf91ee15 (patch) | |
tree | dbd72d0add72d4923244e93e476deeb422b0ff99 /ide-definitions.c | |
parent | 547bfbba7a1ef84d397711882a501fc4914addba (diff) |
cancelling requests
Diffstat (limited to 'ide-definitions.c')
-rw-r--r-- | ide-definitions.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/ide-definitions.c b/ide-definitions.c index d76925b..6c48e26 100644 --- a/ide-definitions.c +++ b/ide-definitions.c @@ -1,3 +1,8 @@ +void definition_cancel_lookup(Ted *ted) { + Definitions *defs = &ted->definitions; + lsp_cancel_request(ted_get_lsp_by_id(ted, defs->last_request_lsp), defs->last_request_id); + defs->last_request_id = 0; +} static SymbolKind symbol_kind_to_ted(LSPSymbolKind kind) { switch (kind) { @@ -51,8 +56,9 @@ void definition_goto(Ted *ted, LSP *lsp, const char *name, LSPDocumentPosition p LSPRequest request = {.type = LSP_REQUEST_DEFINITION}; request.data.definition.position = position; LSPRequestID id = lsp_send_request(lsp, &request); - // @TODO : cancel old request + lsp_cancel_request(lsp, defs->last_request_id); // cancel old request defs->last_request_id = id; + defs->last_request_lsp = lsp->id; defs->last_request_time = ted->frame_time; } else { // just go to the tag @@ -60,12 +66,6 @@ void definition_goto(Ted *ted, LSP *lsp, const char *name, LSPDocumentPosition p } } -void definition_cancel_lookup(Ted *ted) { - Definitions *defs = &ted->definitions; - defs->last_request_id = 0; -} - - void definitions_frame(Ted *ted) { Definitions *defs = &ted->definitions; if (defs->last_request_id && timespec_sub(ted->frame_time, defs->last_request_time) > 0.2) { @@ -193,6 +193,7 @@ void definitions_send_request_if_needed(Ted *ted) { LSPRequestWorkspaceSymbols *syms = &request.data.workspace_symbols; syms->query = str_dup(query); defs->last_request_id = lsp_send_request(lsp, &request); + defs->last_request_lsp = lsp->id; defs->last_request_time = ted->frame_time; free(defs->last_request_query); defs->last_request_query = query; @@ -219,7 +220,7 @@ void definitions_selector_open(Ted *ted) { void definitions_selector_close(Ted *ted) { Definitions *defs = &ted->definitions; definitions_clear_entries(defs); - // @TODO : cancel + lsp_cancel_request(ted_get_lsp_by_id(ted, defs->last_request_lsp), defs->last_request_id); defs->last_request_id = 0; free(defs->last_request_query); defs->last_request_query = NULL; |