summaryrefslogtreecommitdiff
path: root/ide-signature-help.c
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2023-01-07 16:19:58 -0500
committerpommicket <pommicket@gmail.com>2023-01-07 16:19:58 -0500
commitcb55279a20865fcfde23a160233155d23a09a03b (patch)
tree588764775a2f415aa7a78b02bb398578d6df0133 /ide-signature-help.c
parent66da8ac5dcfe02d3aa79f72ba415235eb872ec1d (diff)
hover/signature cancellation
Diffstat (limited to 'ide-signature-help.c')
-rw-r--r--ide-signature-help.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/ide-signature-help.c b/ide-signature-help.c
index 8cabdf7..87eef7d 100644
--- a/ide-signature-help.c
+++ b/ide-signature-help.c
@@ -34,7 +34,8 @@ static void signature_help_send_request(Ted *ted) {
LSPRequest request = {.type = LSP_REQUEST_SIGNATURE_HELP};
LSPRequestSignatureHelp *s = &request.data.signature_help;
s->position = buffer_cursor_pos_as_lsp_document_position(buffer);
- lsp_send_request(lsp, &request);
+ ted_cancel_lsp_request(ted, &help->last_request);
+ help->last_request = lsp_send_request(lsp, &request);
help->retrigger = false;
}
@@ -55,16 +56,24 @@ bool signature_help_is_open(Ted *ted) {
void signature_help_close(Ted *ted) {
- signature_help_clear(&ted->signature_help);
+ SignatureHelp *help = &ted->signature_help;
+ signature_help_clear(help);
+ ted_cancel_lsp_request(ted, &help->last_request);
}
void signature_help_process_lsp_response(Ted *ted, const LSPResponse *response) {
+ SignatureHelp *help = &ted->signature_help;
Settings *settings = ted_active_settings(ted);
if (!settings->signature_help_enabled) return;
if (response->request.type != LSP_REQUEST_SIGNATURE_HELP)
return;
- SignatureHelp *help = &ted->signature_help;
+ if (response->request.id != help->last_request.id) {
+ // stale request
+ return;
+ }
+ help->last_request.id = 0;
+
const LSPResponseSignatureHelp *lsp_help = &response->data.signature_help;
u32 signature_count = arr_len(lsp_help->signatures);
if (signature_count > SIGNATURE_HELP_MAX)