diff options
author | pommicket <pommicket@gmail.com> | 2022-12-29 12:12:36 -0500 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2022-12-29 12:12:36 -0500 |
commit | 18fbb21e6b95139a8890ba4a65f4402df128ac84 (patch) | |
tree | e72f8f462465d14bf48a88372f90d2d347f025c9 /lsp-parse.c | |
parent | 948decc409bac1e3671afc5d0212b4b35c669b4a (diff) |
working hover
Diffstat (limited to 'lsp-parse.c')
-rw-r--r-- | lsp-parse.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lsp-parse.c b/lsp-parse.c index 7141485..c89a8c4 100644 --- a/lsp-parse.c +++ b/lsp-parse.c @@ -408,7 +408,14 @@ static bool parse_signature_help(LSP *lsp, const JSON *json, LSPResponse *respon static bool parse_hover(LSP *lsp, const JSON *json, LSPResponse *response) { LSPResponseHover *hover = &response->data.hover; - JSONObject result = json_force_object(json_get(json, "result")); + JSONValue result_value = json_get(json, "result"); + if (result_value.type == JSON_NULL) + return true; // no results + if (result_value.type != JSON_OBJECT) { + lsp_set_error(lsp, "Bad result type for textDocument/hover response."); + return false; + } + JSONObject result = json_force_object(result_value); JSONValue range = json_object_get(json, result, "range"); parse_range(lsp, json, range, &hover->range); @@ -446,7 +453,7 @@ static bool parse_hover(LSP *lsp, const JSON *json, LSPResponse *response) { if (value.type == JSON_STRING) { contents_string = value.val.string; } else { - lsp_set_error(lsp, "Bad contents field on textDocument/hover response."); + lsp_set_error(lsp, "Bad contents object in textDocument/hover response."); return false; } } |