summaryrefslogtreecommitdiff
path: root/ide-definitions.c
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2023-01-03 23:35:02 -0500
committerpommicket <pommicket@gmail.com>2023-01-03 23:35:02 -0500
commit4e73c6a204383667aad6ce3905e16aee2a172fb6 (patch)
tree1e075fa743ea6277679404f7bfd3caecaa1f4308 /ide-definitions.c
parentb6460a7aac5196b8cb6174bdaa8cc2ab82310380 (diff)
fix double-free response_to
also cancel old workspace/symbols requests
Diffstat (limited to 'ide-definitions.c')
-rw-r--r--ide-definitions.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/ide-definitions.c b/ide-definitions.c
index d86e6b3..67ac51d 100644
--- a/ide-definitions.c
+++ b/ide-definitions.c
@@ -55,7 +55,7 @@ void definition_goto(Ted *ted, LSP *lsp, const char *name, LSPDocumentPosition p
Definitions *defs = &ted->definitions;
if (lsp) {
// cancel old request
- ted_cancel_lsp_request(ted, defs->last_request_lsp, defs->last_request_id);
+ definition_cancel_lookup(ted);
LSPRequestType request_type = LSP_REQUEST_DEFINITION;
switch (type) {
case GOTO_DEFINITION:
@@ -153,6 +153,7 @@ static void definitions_selector_filter_entries(Ted *ted) {
arr_qsort(sel->entries, definition_entry_qsort_cmp);
sel->n_entries = arr_len(sel->entries);
+ sel->cursor = clamp_u32(sel->cursor, 0, sel->n_entries);
}
@@ -232,6 +233,8 @@ void definitions_send_request_if_needed(Ted *ted) {
LSPRequest request = {.type = LSP_REQUEST_WORKSPACE_SYMBOLS};
LSPRequestWorkspaceSymbols *syms = &request.data.workspace_symbols;
syms->query = str_dup(query);
+ // cancel old request
+ definition_cancel_lookup(ted);
defs->last_request_id = lsp_send_request(lsp, &request);
defs->last_request_lsp = lsp->id;
defs->last_request_time = ted->frame_time;