Skip to content

Best practise for maintaining document state on a language server? #273

@ainslec

Description

@ainslec

This is not an issue, so feel free to close this down and direct me to the correct forum for questions, but I have a question regards the tracking of document state by the language server.

I have attached some message listeners to the LSP and see that text deltas are being sent by the protocol correctly. But my question is what is the general mechanism for handling document state on the server side. I would have assumed (in my ignorance) that each time a document was switched on a client that a full version of the document would be supplied to the server, and as the foreground document (of the active window) was edited, the deltas would be supplied. But, by observing the protocol, it seems that only opening of a document on a client will send the initial document, then potentially you could have 1,000 documents open on the client at the same time, and the server must be ready to apply deltas (assuming that the text document synch kind is set to incremental - which I like).

So, is the server meant to maintain state for every opened document, or is there a way for a server to ask for a complete version of a document state when documents are switched (so that only one active document requires its state tracking on the server)?

I'm just trying to figure out best practise for maintaining state. My apologies if this is (and likely is) the wrong place to ask this question, or for not understanding the spec well enough.

Metadata

Metadata

Assignees

No one assigned

    Labels

    *questionIssue represents a question, should be posted to StackOverflow (VS Code)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions