1
0
forked from aniani/vim

patch 9.0.1939: still a problem when processing LSP RPC requests

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>
This commit is contained in:
Yegappan Lakshmanan
2023-09-24 23:38:46 +02:00
committed by Christian Brabandt
parent ceffca683b
commit b80ae6cec3
3 changed files with 81 additions and 18 deletions

View File

@@ -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))