Protocols
Saved & recent

LSP document synchronization

Also called: didOpen, didChange, didClose

Document synchronization keeps a language server’s view aligned with the text being edited, including changes not yet saved to disk. LSP uses document URIs, version numbers and open, change and close notifications. The agreed synchronization mode determines whether a change sends the whole document or an incremental edit. These document versions are unrelated to the LSP revision.

Suppose version 7 contains count=1. An incremental change can replace the final character with 2 and identify the resulting document as version 8. Later analysis should use that updated text. Multiple edits within one change notification apply in sequence, so each edit’s range refers to the document produced by the preceding edit.

Read first
Language Server Protocol
Related
LSP diagnostics, LSP completion, JSON-RPC notifications
Further reading
editor server document count=1 · v7 replace final character count=2 · v8 didChange · document version 8 change applied in memory later analysis request incremental ASCII example
An incremental notification brings the server’s document to version 8 before subsequent analysis uses the changed text.

View in the full Protocols collection