Skip to content

Commit

Permalink
LSP: be more lean #369
Browse files Browse the repository at this point in the history
  • Loading branch information
WebFreak001 committed Apr 29, 2024
1 parent 8de798b commit 654db06
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lsp/source/served/lsp/jsonrpc.d
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,18 @@ private:
throw new Exception("malformed request JSON, must be object");
auto slices = json.parseKeySlices!("id", "result", "error", "method", "params");

if (slices.result.length && slices.error.length)
{
// for supporting non-LSP conforming editors:
// if both result and error is set, do the following rules:
// - if error is `null`, unset `error`
// - otherwise if result is `null`, unset `result`
if (slices.error == "null")
slices.error = "";
else if (slices.result == "null")
slices.result = "";
}

auto id = slices.id;
if (slices.result.length && slices.method.length
|| !slices.result.length && !slices.method.length && !slices.error.length
Expand Down

0 comments on commit 654db06

Please sign in to comment.