Repository navigation
Conversation
`VersionedTextDocumentIdentifier` omitted `version` from its JSON when
`version? = none`. It is also used for LSP's
`OptionalVersionedTextDocumentIdentifier` (the `textDocument` of a
`TextDocumentEdit`), which requires `version : integer | null`, with `null`
for documents whose version is unknown, e.g. ones not open in the editor or
being created. vscode-languageclient rejects a `TextDocumentEdit` without
`version` ("Unknown workspace edit change received"), so code actions and
`workspace/applyEdit` requests could not edit such documents. In particular, a
workspace edit could not create a file with contents.
`version? := none` is now serialized as `"version": null`. Every place where
Lean builds a `VersionedTextDocumentIdentifier` for LSP's non-optional
`VersionedTextDocumentIdentifier` sets the version, so its serialization is
unchanged there. Deserialization still accepts a missing `version`.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Lean's `ToJson`/`FromJson` deriving handlers omit a field named `foo?` when it is `none`, but serialize any other `Option` field as `null`. Since LSP's `OptionalVersionedTextDocumentIdentifier` requires `version` (it is `integer | null`, not optional), the field is now called `version`, and the derived `ToJson` instance replaces the hand-written one. Deserialization still accepts a missing `version`, as `getObjValAs?` treats a missing key as `null`. This is a breaking change for code that constructs or reads `VersionedTextDocumentIdentifier.version?`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
version in VersionedTextDocumentIdentifierversion in VersionedTextDocumentIdentifier json
Contributor
Author
|
downstream |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The adaptation PR for this PR is leanprover/downstream-lean4#224. |
4 tasks done
mhuisi
approved these changes
Nov 5, 2026
mhuisi
left a comment
Contributor
There was a problem hiding this comment.
LGTM. Is this good to merge?
thorimur
marked this pull request as ready for review
November 5, 2026 17:39
Contributor
Author
|
@mhuisi Now it is! :) (I've just updated the PR description.) |
Contributor
Author
|
changelog-server |
…ional-version-null
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes
WorkspaceEdits targeting unopened files. Breaking change: theversion? : Option Natfield ofVersionedTextDocumentIdentifieris nowversion : Option Nat, as LSP requires"version": nullfrom the JSON in theversion := nonecase instead of an omittedversionfield.Closes #16236