Repository navigation
Add sub-ranges for diagnostics and hints - #8254
Merged
Merged
Conversation
saecki
reviewed
May 12, 2026
|
|
||
| /// The possible kinds of span. | ||
| #[derive(Debug)] | ||
| pub enum SpanKind { |
Member
There was a problem hiding this comment.
The SpanKind is a nice touch. The previous way of checking for the different span types felt a little un-rusty in some places :)
isuffix
force-pushed
the
sub-ranges
branch
3 times, most recently
from
May 23, 2026 15:44
6bbcda6 to
fb661c6
Compare
Merged
Collaborator
Author
|
Rebased off main |
laurmaedje
reviewed
May 26, 2026
Collaborator
Author
|
With the new commit, this should be ready. |
Member
|
For fast-forward merging, it's a bit unfortunate if the last two commits go back and forth on the |
Member
|
Thank you, nice work! :) |
ParaN3xus
added a commit
to ParaN3xus/typst.ts
that referenced
this pull request
Jun 9, 2026
ParaN3xus
added a commit
to ParaN3xus/typst.ts
that referenced
this pull request
Jun 9, 2026
ParaN3xus
added a commit
to ParaN3xus/tinymist
that referenced
this pull request
Jun 9, 2026
ParaN3xus
added a commit
to ParaN3xus/tinymist
that referenced
this pull request
Jun 9, 2026
ParaN3xus
added a commit
to ParaN3xus/tinymist
that referenced
this pull request
Jun 9, 2026
ParaN3xus
added a commit
to ParaN3xus/tinymist
that referenced
this pull request
Jun 9, 2026
ParaN3xus
added a commit
to ParaN3xus/tinymist
that referenced
this pull request
Jun 9, 2026
ParaN3xus
added a commit
to ParaN3xus/tinymist
that referenced
this pull request
Jun 9, 2026
ParaN3xus
added a commit
to ParaN3xus/tinymist
that referenced
this pull request
Jun 9, 2026
ParaN3xus
added a commit
to ParaN3xus/tinymist
that referenced
this pull request
Jun 9, 2026
ParaN3xus
added a commit
to ParaN3xus/tinymist
that referenced
this pull request
Jun 10, 2026
ParaN3xus
added a commit
to ParaN3xus/tinymist
that referenced
this pull request
Jun 10, 2026
ParaN3xus
added a commit
to ParaN3xus/tinymist
that referenced
this pull request
Jun 10, 2026
ParaN3xus
added a commit
to ParaN3xus/tinymist
that referenced
this pull request
Jun 10, 2026
Myriad-Dreamin
pushed a commit
to Myriad-Dreamin/tinymist
that referenced
this pull request
Jun 13, 2026
Myriad-Dreamin
pushed a commit
to Myriad-Dreamin/tinymist
that referenced
this pull request
Jun 13, 2026
Myriad-Dreamin
pushed a commit
to Myriad-Dreamin/tinymist
that referenced
this pull request
Jun 13, 2026
Myriad-Dreamin
pushed a commit
to Myriad-Dreamin/tinymist
that referenced
this pull request
Jun 13, 2026
Myriad-Dreamin
pushed a commit
to Myriad-Dreamin/tinymist
that referenced
this pull request
Jun 13, 2026
Myriad-Dreamin
pushed a commit
to Myriad-Dreamin/tinymist
that referenced
this pull request
Jun 13, 2026
Myriad-Dreamin
pushed a commit
to Myriad-Dreamin/tinymist
that referenced
this pull request
Jun 13, 2026
Myriad-Dreamin
pushed a commit
to Myriad-Dreamin/tinymist
that referenced
this pull request
Jun 13, 2026
Myriad-Dreamin
pushed a commit
to Myriad-Dreamin/tinymist
that referenced
this pull request
Jun 13, 2026
Myriad-Dreamin
pushed a commit
to Myriad-Dreamin/tinymist
that referenced
this pull request
Jun 13, 2026
Myriad-Dreamin
pushed a commit
to Myriad-Dreamin/tinymist
that referenced
this pull request
Jun 13, 2026
Myriad-Dreamin
pushed a commit
to Myriad-Dreamin/tinymist
that referenced
this pull request
Jun 13, 2026
Myriad-Dreamin
added a commit
to Myriad-Dreamin/tinymist
that referenced
this pull request
Jun 15, 2026
Part of the Typst 0.15 cleanup stack. This slice covers diagnostics/span migration and the minimal query prerequisites needed before the later export and text accessor slices. ## Upstream Typst Changes - [`typst/typst#8052`](typst/typst#8052) makes diagnostic hints carry span metadata. Tinymist renders the hint message payload instead of formatting the whole spanned wrapper. - [`typst/typst#8254`](typst/typst#8254) changes diagnostic, user-action, and test-range span handling. Tinymist updates LSP diagnostics, user-action conversion, and range-sensitive tests for the new span shape. - [`typst/typst#8188`](typst/typst#8188) changes syntax diagnostics. Tinymist updates syntax matchers and diagnostics conversion paths that inspect syntax-side errors. - [`typst/typst#8307`](typst/typst#8307) changes bibliography lookup. Tinymist now finds bibliography elements through the document introspector and packs them back to `BibliographyElem`. - Typst 0.15 deprecates rooted virtual-path access through `as_rooted_path`; diagnostics now use the slash-form virtual path accessor for extension checks. ## Tinymist Changes - Updates `tinymist-world` diagnostic rendering for spanned hint values. - Updates `tinymist-query`, `tinymist-analysis`, `tinymist-lint`, and debug-facing syntax diagnostics for the new span and syntax diagnostic APIs. - Updates user-action span conversion and affected test ranges. - Updates code-context path evaluation to construct `RangeMapper` from an iterator, matching the lint expectations of the current toolchain. - Carries the small bibliography lookup prerequisite in this slice so later query-oriented slices build on the updated Typst API. --------- Co-authored-by: paran3xus <[email protected]>
Myriad-Dreamin
pushed a commit
to Myriad-Dreamin/typst.ts
that referenced
this pull request
Jun 15, 2026
Myriad-Dreamin
pushed a commit
to Myriad-Dreamin/typst.ts
that referenced
this pull request
Jun 15, 2026
Myriad-Dreamin
added a commit
to Myriad-Dreamin/tinymist
that referenced
this pull request
Jun 15, 2026
Part of the Typst 0.15 cleanup stack. This slice covers diagnostics/span migration and the minimal query prerequisites needed before the later export and text accessor slices. ## Upstream Typst Changes - [`typst/typst#8052`](typst/typst#8052) makes diagnostic hints carry span metadata. Tinymist renders the hint message payload instead of formatting the whole spanned wrapper. - [`typst/typst#8254`](typst/typst#8254) changes diagnostic, user-action, and test-range span handling. Tinymist updates LSP diagnostics, user-action conversion, and range-sensitive tests for the new span shape. - [`typst/typst#8188`](typst/typst#8188) changes syntax diagnostics. Tinymist updates syntax matchers and diagnostics conversion paths that inspect syntax-side errors. - [`typst/typst#8307`](typst/typst#8307) changes bibliography lookup. Tinymist now finds bibliography elements through the document introspector and packs them back to `BibliographyElem`. - Typst 0.15 deprecates rooted virtual-path access through `as_rooted_path`; diagnostics now use the slash-form virtual path accessor for extension checks. ## Tinymist Changes - Updates `tinymist-world` diagnostic rendering for spanned hint values. - Updates `tinymist-query`, `tinymist-analysis`, `tinymist-lint`, and debug-facing syntax diagnostics for the new span and syntax diagnostic APIs. - Updates user-action span conversion and affected test ranges. - Updates code-context path evaluation to construct `RangeMapper` from an iterator, matching the lint expectations of the current toolchain. - Carries the small bibliography lookup prerequisite in this slice so later query-oriented slices build on the updated Typst API. --------- Co-authored-by: paran3xus <[email protected]>
Myriad-Dreamin
added a commit
to Myriad-Dreamin/tinymist
that referenced
this pull request
Jun 15, 2026
Part of the Typst 0.15 cleanup stack. This slice covers diagnostics/span migration and the minimal query prerequisites needed before the later export and text accessor slices. ## Upstream Typst Changes - [`typst/typst#8052`](typst/typst#8052) makes diagnostic hints carry span metadata. Tinymist renders the hint message payload instead of formatting the whole spanned wrapper. - [`typst/typst#8254`](typst/typst#8254) changes diagnostic, user-action, and test-range span handling. Tinymist updates LSP diagnostics, user-action conversion, and range-sensitive tests for the new span shape. - [`typst/typst#8188`](typst/typst#8188) changes syntax diagnostics. Tinymist updates syntax matchers and diagnostics conversion paths that inspect syntax-side errors. - [`typst/typst#8307`](typst/typst#8307) changes bibliography lookup. Tinymist now finds bibliography elements through the document introspector and packs them back to `BibliographyElem`. - Typst 0.15 deprecates rooted virtual-path access through `as_rooted_path`; diagnostics now use the slash-form virtual path accessor for extension checks. ## Tinymist Changes - Updates `tinymist-world` diagnostic rendering for spanned hint values. - Updates `tinymist-query`, `tinymist-analysis`, `tinymist-lint`, and debug-facing syntax diagnostics for the new span and syntax diagnostic APIs. - Updates user-action span conversion and affected test ranges. - Updates code-context path evaluation to construct `RangeMapper` from an iterator, matching the lint expectations of the current toolchain. - Carries the small bibliography lookup prerequisite in this slice so later query-oriented slices build on the updated Typst API. --------- Co-authored-by: paran3xus <[email protected]>
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 adds sub-ranges for diagnostics, although does not add any uses of them yet. A following PR will add warnings for raw syntax that will make use of sub-ranges and sub-ranges on hints.
This PR is dependent on #8188. The first new commit is "Don't use raw range spans for imported files in
definition.rs"Why are sub-ranges necessary?
When we assign spans to a concrete syntax tree, we assign targetable numbers that correspond to a range in the source. However, spans only exist on full nodes in the tree, and do not allow targeting parts of a node, or ranges of text across multiple nodes. Adding sub-ranges gives us much more flexibility to create good diagnostic messages that target exactly the desired text.
Why not use raw-range spans instead?
Sub-ranges are relative to the overall range for a span so they aren't invalidated when we insert new text into the syntax tree when parsing incrementally. Absolute raw-ranges would need to be searched for and globally updated on every reparse.
What else changed?
synthesize_withevolves a lot over all of the commits, although I am open to changing it. However, leavingInnerNode::synthesize_withas a separate function caused too many non-local changes, so I just inlined it tosynthesize_with.RangeMapperquite a bit and notably removed theOptionfrom the range return by usingpartition_pointand returning a result on construction if any invariants weren't followed.SpanNumbertype that solely interacts with theSource::rangesince sub-ranges add a new way to produce ranges that would have madeSource::rangetaking a wholeSpaneasy to use incorrectly.SpanNumberalso made it easier to distinguish the kinds ofLinkedNode::findoperation, and I made it work for raw-range spans.SpanNumber, and I settled on a.get()method returning the new unpackedSpanKindenum that can be explicitly matched against.SubRangeand use aNonZeroU32for the end index for null-optimization and to ensure they are non-empty ranges. Most uses take anOption<SubRange>which is conviently produced bySubRange::newrequiring a non-empty range.DiagSpanandDiagSpanKindto distinguish diagnostic spans with sub-ranges from normal spans.DiagSpancontaining an extra 64 bits also allows us to store larger ranges than just 23 bits for externally loaded files by storing a 46-bit start index within theSpanand another 46-bit end index in the extra space.2^23instead of saturating at2^23-1like the end index.