You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(lsp): track document versions and include in publish_diagnostics (#544)
* feat(lsp): track document versions and include in publish_diagnostics (#478)
Add a document_versions map to the LSP Backend that tracks the version
number reported by the client on did_open and did_change events. The
tracked version is passed to publish_diagnostics instead of None,
allowing editors to correctly associate diagnostics with the document
revision they were computed against.
- Add document_versions field to Backend struct
- Store version on did_open and did_change, remove on did_close
- Add get_document_version helper method
- Replace None with tracked version in validate_from_content_and_publish
- Keep None for did_close (clearing diagnostics for closed documents)
- Add 5 unit tests and 1 integration test for version lifecycle
* fix(lsp): address review findings for document version tracking (#478)
* fix(lsp): atomize version+content updates, fix version tracking on empty changes (#478)
- Hold both documents and document_versions write locks simultaneously
in handle_did_open and handle_did_change so readers never see a state
where content is updated but version is not (or vice versa).
- Always update document version on did_change regardless of whether
content_changes is empty, aligning with LSP spec where
VersionedTextDocumentIdentifier.version is authoritative.
- Restore get_document_version to pub(crate) visibility and remove
duplicate integration test (unit tests in backend/tests.rs cover
direct version access).
- Fix stale comment in integration test to accurately describe the
test's approach.
* fix(lsp): correct misleading comment about lock drop order
* docs: add changelog entry for LSP document version tracking (#478)
* fix(lsp): apply rustfmt formatting to LSP backend code
Fixes formatting issues detected in CI Format Check.
* fix(lsp): address race condition and misleading comments in version tracking
Addresses three Copilot review comments:
1. Fixed TOCTOU race in validate_from_content_and_publish: capture version
at the same time as content snapshot to ensure diagnostics are published
with the version matching the content they were validated against, not a
newer version from concurrent did_change events.
2. Corrected misleading comments in handle_did_open/did_change about lock
guarantees. The comments suggested locks prevent readers from seeing
inconsistency, but that's only true if readers atomically capture both
values together (which they now do).
3. Clarified integration test comment to explain why it doesn't assert
version field in publish_diagnostics (requires consuming socket messages).
Referenced unit tests in backend/tests.rs that verify version lifecycle.
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -63,6 +63,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
63
63
-**`LintConfig` cheap cloning**: Introduced `Arc<ConfigData>` inner struct to hold all serializable fields. Cloning a `LintConfig` (e.g., in `validate_project` / `validate_project_with_registry` parallel dispatch) now bumps an `Arc` refcount instead of deep-copying `Vec<String>` fields and nested structs. Mutations use `Arc::make_mut` for copy-on-write semantics, so the allocation only occurs when the `Arc` is actually shared (#467)
64
64
65
65
### Fixed
66
+
-**LSP document version tracking**: The LSP backend now tracks document versions reported by the client (`did_open`, `did_change`) and includes them in all `publish_diagnostics` calls. Editors that inspect diagnostic version tags (e.g., for stale-result suppression) now receive accurate version numbers instead of `None`. Version and content updates are atomized under a single lock acquisition so readers never observe a state where content and version are out of sync. Empty `did_change` notifications (no content changes) also correctly advance the tracked version per the LSP spec (#478)
66
67
-**Frontmatter leading newline stripped**: `split_frontmatter()` no longer includes the newline that follows the opening `---` delimiter in the extracted frontmatter string. Downstream validators (`AgentValidator`, `AmpValidator`, `KiroSteeringValidator`) have been updated to compute correct 1-based line numbers; diagnostic line numbers for AMP-001, CC-AG-007, and KIRO-001 through KIRO-004 are now accurate (#482)
67
68
-**Empty-frontmatter panic guard**: `split_frontmatter()` now uses `str::get()` instead of direct slice indexing when extracting frontmatter content, preventing an index-out-of-bounds panic on files with an opening `---` delimiter but no content (#482)
68
69
-**Predictable UUID Generation for Telemetry**: Replaced the custom, insecure random number generator with a cryptographically secure pseudo-random number generator (CSPRNG) using the `uuid` crate. Ensures telemetry installation IDs are unpredictable and unique.
0 commit comments