diff options
author | pommicket <pommicket@gmail.com> | 2022-12-22 18:55:15 -0500 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2022-12-22 18:56:41 -0500 |
commit | 91ff61cc22c08e2c247b6b689561e6d18cf276e7 (patch) | |
tree | f8025b141122ba219fbe45a1a9c2770e49d76905 /lsp-parse.c | |
parent | 2667c71e71d77ecade1142c133ed7181ce38c664 (diff) |
detail text
Diffstat (limited to 'lsp-parse.c')
-rw-r--r-- | lsp-parse.c | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/lsp-parse.c b/lsp-parse.c index 6167cc8..8afca07 100644 --- a/lsp-parse.c +++ b/lsp-parse.c @@ -130,31 +130,32 @@ static bool parse_completion(LSP *lsp, const JSON *json, LSPResponse *response) .new_text = item->label }; - JSONValue sort_text_value = json_object_get(json, item_object, "sortText"); - if (sort_text_value.type == JSON_STRING) { + JSONString sort_text = json_object_get_string(json, item_object, "sortText"); + if (sort_text.pos) { // LSP allows using a different string for sorting. - item->sort_text = lsp_response_add_json_string(response, - json, sort_text_value.val.string); + item->sort_text = lsp_response_add_json_string(response, json, sort_text); } - JSONValue filter_text_value = json_object_get(json, item_object, "filterText"); - if (filter_text_value.type == JSON_STRING) { + JSONString filter_text = json_object_get_string(json, item_object, "filterText"); + if (filter_text.pos) { // LSP allows using a different string for filtering. - item->filter_text = lsp_response_add_json_string(response, - json, filter_text_value.val.string); + item->filter_text = lsp_response_add_json_string(response, json, filter_text); } - JSONValue text_type_value = json_object_get(json, item_object, "insertTextFormat"); - if (text_type_value.type == JSON_NUMBER) { - double type = text_type_value.val.number; - if (type != LSP_TEXT_EDIT_PLAIN && type != LSP_TEXT_EDIT_SNIPPET) { - lsp_set_error(lsp, "Bad InsertTextFormat: %g", type); + double edit_type = json_object_get_number(json, item_object, "insertTextFormat"); + if (!isnan(edit_type)) { + if (edit_type != LSP_TEXT_EDIT_PLAIN && edit_type != LSP_TEXT_EDIT_SNIPPET) { + lsp_set_error(lsp, "Bad InsertTextFormat: %g", edit_type); return false; } - item->text_edit.type = (LSPTextEditType)type; + item->text_edit.type = (LSPTextEditType)edit_type; } - // @TODO: detail + + JSONString detail_text = json_object_get_string(json, item_object, "detail"); + if (detail_text.pos) { + item->detail = lsp_response_add_json_string(response, json, detail_text); + } // @TODO(eventually): additionalTextEdits // (try to find a case where this comes up) |