summaryrefslogtreecommitdiffstats
path: root/src/channel.c
diff options
context:
space:
mode:
authorYegappan Lakshmanan <yegappan@yahoo.com>2023-09-24 23:38:46 +0200
committerChristian Brabandt <cb@256bit.org>2023-09-24 23:38:46 +0200
commitb80ae6cec34639abfb1a7080fb633346a81a5770 (patch)
treef718fb24f66452f57e78e1e37fdfa650f78e906f /src/channel.c
parentceffca683ba986065e583d02e7ace964efdb256e (diff)
patch 9.0.1939: still a problem when processing LSP RPC requestsv9.0.1939
Problem: still a problem when processing LSP RPC requests Solution: When processing async LSP RPC requests, compare sequence numbers only in response messages A LSP request message can be sent to the language server either synchronously (ch_evalexpr) or asynchronously (ch_sendexpr). In both cases, when looking for response messages by using the sequence number, LSP requests messages from the language server with the same sequence number should not be used. Patch 9.0.1927 fixed this issue for synchronous requests. This PR fixes the issue for asynchronous requests and adds additional tests. closes: #13158 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Diffstat (limited to 'src/channel.c')
-rw-r--r--src/channel.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/src/channel.c b/src/channel.c
index 1de376884a..38f610a9fb 100644
--- a/src/channel.c
+++ b/src/channel.c
@@ -3052,13 +3052,27 @@ may_invoke_callback(channel_T *channel, ch_part_T part)
{
// JSON or JS or LSP mode: invoke the one-time callback with the
// matching nr
- for (cbitem = cbhead->cq_next; cbitem != NULL; cbitem = cbitem->cq_next)
- if (cbitem->cq_seq_nr == seq_nr)
+ int lsp_req_msg = FALSE;
+
+ // Don't use a LSP server request message with the same sequence number
+ // as the client request message as the response message.
+ if (ch_mode == CH_MODE_LSP && argv[1].v_type == VAR_DICT
+ && dict_has_key(argv[1].vval.v_dict, "method"))
+ lsp_req_msg = TRUE;
+
+ if (!lsp_req_msg)
+ {
+ for (cbitem = cbhead->cq_next; cbitem != NULL;
+ cbitem = cbitem->cq_next)
{
- invoke_one_time_callback(channel, cbhead, cbitem, argv);
- called_otc = TRUE;
- break;
+ if (cbitem->cq_seq_nr == seq_nr)
+ {
+ invoke_one_time_callback(channel, cbhead, cbitem, argv);
+ called_otc = TRUE;
+ break;
+ }
}
+ }
}
if (seq_nr > 0 && (ch_mode != CH_MODE_LSP || called_otc))