Skip to content

Commit a2028be

Browse files
imbantdbaeumer
andauthored
Ensure document state synchronization before client requests (#2017)
* Added description about the order of `signatureHelp` and `didChange` Copy this [discussion](#2011 (comment)) to the document * Revert the specific description about the order of didChange * Ensure document state synchronization before client requests * Ensure document state synchronization before client requests * add a concrete example * add a concrete example --------- Co-authored-by: Dirk Bäumer <[email protected]>
1 parent df5f3bf commit a2028be

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

_specifications/lsp/3.17/textDocument/didChange.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22

33
The document change notification is sent from the client to the server to signal changes to a text document. Before a client can change a text document it must claim ownership of its content using the `textDocument/didOpen` notification. In 2.0 the shape of the params has changed to include proper version numbers.
44

5+
Before requesting information from the server (e.g., `textDocument/completion` or `textDocument/signatureHelp`), the client must ensure that the document's state is synchronized with the server to guarantee reliable results.
6+
7+
The following example shows how the client should synchronize the state when the user has continuous input, assuming user input triggered `textDocument/completion`:
8+
9+
| Document Version | User Input | Client Behavior | Request |
10+
| ---------------- | ------------------- | ----------------------------------------------- | ------------------------- |
11+
| 5 | document change one | sync document `v5` to the server | `textDocument/didChange` |
12+
| 5 | - | request from the server, based on document `v5` | `textDocument/completion` |
13+
| 6 | document change two | sync document `v6` to the server | `textDocument/didChange` |
14+
515
_Client Capability_:
616
See general synchronization [client capabilities](#textDocument_synchronization_cc).
717

_specifications/lsp/3.18/textDocument/didChange.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22

33
The document change notification is sent from the client to the server to signal changes to a text document. Before a client can change a text document it must claim ownership of its content using the `textDocument/didOpen` notification. In 2.0 the shape of the params has changed to include proper version numbers.
44

5+
Before requesting information from the server (e.g., `textDocument/completion` or `textDocument/signatureHelp`), the client must ensure that the document's state is synchronized with the server to guarantee reliable results.
6+
7+
The following example shows how the client should synchronize the state when the user has continuous input, assuming user input triggered `textDocument/completion`:
8+
9+
| Document Version | User Input | Client Behavior | Request |
10+
| ---------------- | ------------------- | ----------------------------------------------- | ------------------------- |
11+
| 5 | document change one | sync document `v5` to the server | `textDocument/didChange` |
12+
| 5 | - | request from the server, based on document `v5` | `textDocument/completion` |
13+
| 6 | document change two | sync document `v6` to the server | `textDocument/didChange` |
14+
515
_Client Capability_:
616
See general synchronization [client capabilities](#textDocument_synchronization_cc).
717

0 commit comments

Comments
 (0)