patch 9.0.1924: LSP server message still wrongly handled (after 9.0.1922)

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>
diff --git a/src/testdir/test_channel.vim b/src/testdir/test_channel.vim
index 5a35083..edfd56e 100644
--- a/src/testdir/test_channel.vim
+++ b/src/testdir/test_channel.vim
@@ -2481,6 +2481,14 @@
 " 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 @@
   " 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)