Skip to content

Commit

Permalink
lsp: Result should be null unstead of empty object (#1328)
Browse files Browse the repository at this point in the history
  • Loading branch information
V-FEXrt authored Jun 29, 2023
1 parent 50d6db0 commit c294171
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions tools/lsp-wake/json_converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,6 @@ JAST highlightsToJSON(JAST receivedMessage, const std::vector<Location> &occurre

JAST hoverInfoToJSON(JAST receivedMessage, const std::vector<SymbolDefinition> &hoverInfoPieces) {
JAST message = createResponseMessage(std::move(receivedMessage));
JAST &result = message.add("result", JSON_OBJECT);

std::string value;
for (const SymbolDefinition &def : hoverInfoPieces) {
Expand All @@ -321,11 +320,16 @@ JAST hoverInfoToJSON(JAST receivedMessage, const std::vector<SymbolDefinition> &
}
value += def.outerDocumentation + "\n\n";
}
if (!value.empty()) {
JAST &contents = result.add("contents", JSON_OBJECT);
contents.add("kind", "markdown");
contents.add("value", value.c_str());

if (value.empty()) {
message.add("result", JSON_NULLVAL);
return message;
}

JAST &result = message.add("result", JSON_OBJECT);
JAST &contents = result.add("contents", JSON_OBJECT);
contents.add("kind", "markdown");
contents.add("value", value.c_str());
return message;
}

Expand Down

0 comments on commit c294171

Please sign in to comment.