From 654db06e58391227c56d2d92f92497bccf33e12c Mon Sep 17 00:00:00 2001 From: WebFreak001 Date: Tue, 30 Apr 2024 01:19:52 +0200 Subject: [PATCH] LSP: be more lean #369 --- lsp/source/served/lsp/jsonrpc.d | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lsp/source/served/lsp/jsonrpc.d b/lsp/source/served/lsp/jsonrpc.d index a6cc70b..94fe18a 100644 --- a/lsp/source/served/lsp/jsonrpc.d +++ b/lsp/source/served/lsp/jsonrpc.d @@ -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