lite-xl / lite-xl-lsp

LSP Plugin for Lite XL editor
MIT License
160 stars 21 forks source link

textDocument/didChange full send should be array #21

Closed leafi closed 2 years ago

leafi commented 2 years ago

When telling the LSP about content changes, the path for when sync_kind is .Full and the server doesn't support incremental changes sends a manually constructed textDocument/didChange event. See lsp/init.lua L961.

The quite simple nelua-lsp server can't cope with the way contentChanges is written.

It's written as a field that is one object, containing .text with all the text -- but according to the LSP spec DidChangeTextDocumentParams definition, .contentChanges must be an array of change events.

I've changed lsp/init.lua L970, L972 locally to add array [ ] braces around the constructed text change event.

This stops nelua-lsp throwing a bunch of errors trying to index .contentChanges[1].text.

jgmdev commented 2 years ago

Thanks a lot for investigating this!

I remember when implementing the lsp client initially I didn't supported sending incremental changes so client didn't reported support for incremental changes and the data was sent as you pointed out, it worked with the servers I tested or that is what I thought, crazy hehe, maybe it happened after implementing the sending raw functionality, those where some long nights trying to understand spec :).

Looking at what you say then it should look like this:

.. '"contentChanges": ['
.. '{"text": "'..text..'"}'
.. "]"

Will commit this change right now!