Re: [vim/vim] runtime(doc): a server request with a String id cannot be answered (PR #21114)

Yegappan Lakshmanan (Vim Github Repository) <[email protected]>
Newsgroups gmane.editors.vim.devel
Message-ID <vim/vim/pull/21114/[email protected]>
yegappan left a comment (vim/vim#21114)

> @chrisbra and all, Before documenting this limitation, is it worth removing instead? The restriction looks narrower than the current check makes it.
> 
> In `ch_sendexpr()` the "id" is only ever used to match a reply: it is handed to `channel_set_req_callback()` in `send_common()`, and only when a callback was given. For `ch_evalexpr()`, and for `ch_sendexpr()` with a callback, Vim assigns `++channel->ch_last_msg_id` and overwrites whatever the caller put in "id", so a String there is already beside the point. For a plain `ch_sendexpr()` with no callback, the value is read once into a local that nothing goes on to use, and the dictionary is encoded as it stands.
> 
> That last case is the one that matters here. A message answering a request the server made carries the server's id back and waits for nothing. Vim has no reason to look at it, but the type check rejects it before it gets that far, so a server naming its requests with a string cannot be answered at all. python-lsp-server does exactly that: its `workspace/applyEdit` arrives with `"id": "258cf855-32f3-4cb2-8f33-86215a3e4b25"`, and answering it gives E475.
> 
> The change would be to move the `callback_present` test above the type check and require a Number only when Vim has to track the message: DAP, `eval`, or a callback. Otherwise pass the dictionary through and leave the local id at zero. About ten lines, plus a test that a String id is answered as it came.
> 
> If that sounds right I will prepare it, and this doc patch can either go or say the opposite.

I agree.  This will be good to add.  A request from a Vim LSP plugin to the LSP server should only contain a number as an identifier.  But an LSP server may send a request to the plugin with an UUID as the identifier and the plugin needs to respond to that request with the UUID.  In this case, Vim should not enforce the type check.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/vim/vim/pull/21114#issuecomment-5381256607
You are receiving this because you are subscribed to this thread.

Message ID: <vim/vim/pull/21114/[email protected]>

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups "vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion visit https://groups.google.com/d/msgid/vim_dev/vim/vim/pull/21114/c5381256607%40github.com.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.