diff options
author | Yegappan Lakshmanan <yegappan@yahoo.com> | 2023-09-21 16:36:28 +0200 |
---|---|---|
committer | Christian Brabandt <cb@256bit.org> | 2023-09-21 16:36:28 +0200 |
commit | 1926ae41845c3b6e2045b29225365c8a2e4eb1da (patch) | |
tree | 4244ed2884cc22c4cbc7383c91f4d3fc3283ee46 /src/testdir/test_channel.vim | |
parent | db54e989b5cff3cc6442dfc500e3962cc1c0b6d0 (diff) |
patch 9.0.1924: LSP server message still wrongly handled (after 9.0.1922)v9.0.1924
Problem: LSP server message still wrongly handled (after 9.0.1922)
Solution: Handle 'method' messages properly, don't discard them, add
tests.
closes: #13141
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Diffstat (limited to 'src/testdir/test_channel.vim')
-rw-r--r-- | src/testdir/test_channel.vim | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/testdir/test_channel.vim b/src/testdir/test_channel.vim index 5a35083248..edfd56e0ba 100644 --- a/src/testdir/test_channel.vim +++ b/src/testdir/test_channel.vim @@ -2481,6 +2481,14 @@ endfunc " Test for the 'lsp' channel mode func LspCb(chan, msg) call add(g:lspNotif, a:msg) + if a:msg->has_key('method') + " Requests received from the LSP server + if a:msg['method'] == 'server-req-in-middle' + \ && a:msg['params']['text'] == 'server-req' + call ch_sendexpr(a:chan, #{method: 'server-req-in-middle-resp', + \ id: a:msg['id'], params: #{text: 'client-resp'}}) + endif + endif endfunc func LspOtCb(chan, msg) @@ -2652,6 +2660,19 @@ func LspTests(port) " send a ping to make sure communication still works call assert_equal('alive', ch_evalexpr(ch, #{method: 'ping'}).result) + " Test for processing a request message from the server while the client + " is waiting for a response with the same identifier. + let g:lspNotif = [] + let resp = ch_evalexpr(ch, #{method: 'server-req-in-middle', + \ params: #{text: 'client-req'}}) + call assert_equal(#{jsonrpc: '2.0', id: 28, + \ result: #{text: 'server-resp'}}, resp) + call assert_equal([ + \ #{id: -1, jsonrpc: '2.0', method: 'server-req-in-middle', + \ params: #{text: 'server-notif'}}, + \ #{id: 28, jsonrpc: '2.0', method: 'server-req-in-middle', + \ params: #{text: 'server-req'}}], g:lspNotif) + " Test for invoking an unsupported method let resp = ch_evalexpr(ch, #{method: 'xyz', params: {}}, #{timeout: 200}) call assert_equal({}, resp) |