swyddfa / lsp-devtools

Tooling for working with language servers and clients.
https://lsp-devtools.readthedocs.io/en/latest/
47 stars 8 forks source link

Refactor agent implementation #165

Closed alcarney closed 2 months ago

alcarney commented 2 months ago

Rather than try to embed a JSON-RPC message inside another JSON-RPC message (i.e. the MessageText notification) this commit changes the agent to forward the message onto the inspector program (mostly) unmodified.

The most important detail is that we leave the message encoded as bytes, this way we don't introduce any errors caused by Python counting the length of unicode characters differently, depending on if they are a string or a sequence of bytes. Closes #157

>>> len('∊')
1
>>> len('∊'.encode())
3

As for the metadata fields that were included in the MessageText, these are now passed as additional headers prepended to the captured message