LSP §9b: incremental text sync

textDocument/didChange now applies ranged content changes instead of
requiring the whole buffer per keystroke. New pure sync::apply_changes
applies each change against the document as the previous ones left it
(fresh line table per change), clamping inherited from convert.rs and a
backwards range read as a pure insertion — the one rule that cannot lose
text. One notification stays one reparse / one generation bump / one
publish. Full-sync clients (rangeless changes) keep byte-identical
behavior; save advertises includeText: false and didSave still honours
text when sent.

35 tests added (28 unit incl. a 400-sequence randomized cross-check
against an independent reference model and QA's surrogate/CRLF/final-
newline attacks, 6 server-level, 1 e2e pinning the wire capability
shape). QA's one finding — CRLF split across two same-position inserts
in one batch lands \n\r — is pre-existing convert.rs behavior, pinned
by test, unreachable by real clients; see the feature README.

docs/features/incremental-sync/README.md

Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
lucioandClaude Fable 5 committed 2026-08-26 11:49:58 -07:00
1 parent aa303ce9ae
commit c2ea1a11f6
8 files changed
+1200 -20

No files matched your search

+5 -2
View File
@@ -36,9 +36,12 @@ of squiggles for one file is the classic way to ship this feature wrong.
full report — a cheap, correct answer. The error the coarse direction
cannot make is the expensive one: a stale `unchanged` is a wrong squiggle
left on screen. (The brief suggested `generation/doc-version`; the server
does not track document versions at all — full-text sync ignores them — so
does not track document versions at all — the sync path ignores them — so
the second half would have been a constant. One number, documented, beats a
format that implies a precision that is not there.)
format that implies a precision that is not there.) *(Still true after
incremental sync, 2026-08-26: `DidChangeTextDocumentParams.version` is
unread, and one notification is still exactly one generation bump however
many ranges it carried.)*
- **`inter_file_dependencies: true` is honest.** A save rebuilds the
workspace index, and a buffer's diagnostics are computed against that index
(`resolve_external` in `state.rs`), so a save in file A really can change