diff options
author | pommicket <pommicket@gmail.com> | 2022-12-28 17:53:22 -0500 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2022-12-28 17:53:22 -0500 |
commit | 8ef7a72c55e66c097c0130ab17e2062ef75e4723 (patch) | |
tree | 06a83cdddb4179b78292d6c5bb5a30b607551702 /signature-help.c | |
parent | dce1a94e3be8dc4b702d02d901d9b38c6f6a41ce (diff) |
syntax highlighting for JSON, and XML as a separate language
Diffstat (limited to 'signature-help.c')
-rw-r--r-- | signature-help.c | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/signature-help.c b/signature-help.c index 3951c29..1db8104 100644 --- a/signature-help.c +++ b/signature-help.c @@ -1,17 +1,38 @@ // deals with textDocument/signatureHelp LSP requests +static void signature_help_clear(SignatureHelp *help) { + for (int i = 0; i < help->signature_count; ++i) { + Signature sig = help->signatures[i]; + free(sig.label_pre); + free(sig.label_active); + free(sig.label_post); + } + memset(help->signatures, 0, sizeof help->signatures); + help->signature_count = 0; +} + void signature_help_send_request(Ted *ted) { + SignatureHelp *help = &ted->signature_help; Settings *settings = ted_active_settings(ted); - if (!settings->signature_help) return; + if (!settings->signature_help) { + signature_help_clear(help); + return; + } TextBuffer *buffer = ted->active_buffer; - if (!buffer) return; + if (!buffer) { + signature_help_clear(help); + return; + } LSP *lsp = buffer_lsp(buffer); - if (!lsp) return; + if (!lsp) { + signature_help_clear(help); + return; + } 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->signature_help.retrigger = false; + help->retrigger = false; } void signature_help_retrigger(Ted *ted) { @@ -29,15 +50,6 @@ bool signature_help_is_open(Ted *ted) { return ted->signature_help.signature_count > 0; } -static void signature_help_clear(SignatureHelp *help) { - for (int i = 0; i < help->signature_count; ++i) { - Signature sig = help->signatures[i]; - free(sig.label_pre); - free(sig.label_active); - free(sig.label_post); - } - memset(help->signatures, 0, sizeof help->signatures); -} void signature_help_close(Ted *ted) { signature_help_clear(&ted->signature_help); |