Closed mathieumontgomery closed 8 months ago
This might sound strange, but if you comment out the calls to ls.workspace.update_text_document
and ls.workspace.put_text_document
does it work as expected?
The LanguageServer
class automatically handles these messages for you, so chances are in your server these changes are being applied twice - resulting in the hello.oo
you see in your second example
Oh... Yes, now it's working. I've been blindly following the documentation of the DidChangeTextDocumentParams
class, assuming I had to apply it to the workspace...
content_changes: List[TextDocumentContentChangeEvent] = attrs.field()
"""The actual content changes. The content changes describe single state changes
to the document. So if there are two content changes c1 (at array index 0) and
c2 (at array index 1) for a document in state S then c1 moves the document from
S to S' and c2 from S' to S''. So c1 is computed on the state S and c2 is computed
on the state S'.
To mirror the content of a document using change events use the following approach:
- start with the same initial content
- apply the 'textDocument/didChange' notifications in the order you receive them.
- apply the `TextDocumentContentChangeEvent`s in a single notification in the order
you receive them."""
Thank you for the quick answer, and sorry for the inconvenience !
No worries!
Hello, it seems that
ls.workspace.update_text_document()
does not work properly. When I delete a character, it sometimes deletes 2 characters, and when I add one, it sometimes adds the same twice. I've tested using this server:I tested in IntelliJ IDEA and VS Code with the same results. Example in a file named
test.txt
with this content:If I remove the
.
at the end, I will get these logs:If I add an
o
at the end, I will see:I'm using pygls version 1.2.1 in python 3.8.