diff options
author | pommicket <pommicket@gmail.com> | 2022-12-30 14:40:47 -0500 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2022-12-30 14:40:47 -0500 |
commit | f2c8a3a77fdd7f397e04edcaf5dae5e7777f03b6 (patch) | |
tree | 337883c076b415fa50983a2cf3b5335aafded2e9 /ide-definitions.c | |
parent | 91fc9b10e1700b482b13af1d25d95d80085a9b79 (diff) |
better ted_active_lsp, fix memory bug
Diffstat (limited to 'ide-definitions.c')
-rw-r--r-- | ide-definitions.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/ide-definitions.c b/ide-definitions.c index 4dbe9d2..fa4d999 100644 --- a/ide-definitions.c +++ b/ide-definitions.c @@ -194,7 +194,10 @@ void definitions_send_request_if_needed(Ted *ted) { void definitions_selector_open(Ted *ted) { Definitions *defs = &ted->definitions; definitions_clear_entries(defs); - LSP *lsp = buffer_lsp(ted->prev_active_buffer); + LSP *lsp = ted->prev_active_buffer + ? buffer_lsp(ted->prev_active_buffer) + : ted_active_lsp(ted); + if (lsp) { definitions_send_request_if_needed(ted); } else { @@ -231,12 +234,17 @@ void definitions_selector_update(Ted *ted) { arr_foreach_ptr(defs->selector_all_definitions, SymbolInfo, info) { if (strcmp(info->name, chosen) == 0) { if (info->from_lsp) { + // NOTE: we need to get this before calling menu_close, + // since that clears selector_all_definitions + LSPDocumentPosition position = info->position; + menu_close(ted); - ted_go_to_lsp_document_position(ted, NULL, info->position); + ted_go_to_lsp_document_position(ted, NULL, position); } else { menu_close(ted); tag_goto(ted, chosen); } + break; } } |