fix(genspec-tui): drop the YAML position workarounds, upgrade core to v0.0.3 - #71
Merged
Merged
Conversation
… v0.0.3
The spec pane lays the lexer's tokens out by position to colour them. Two
workarounds stood between it and the YAML lexer, both now fixed upstream in
go-openapi/core v0.0.3.
A YAML block collection has no "{" / "[" / "}" / "]" character, so the lexer
had nothing to point its container delimiters at. It reported the opener at the
first entry's separator — a line BELOW the key it precedes — and the closer at
line 0 column 0, which is not a position at all. The accumulator therefore had
to sort each line's runs by column and drop the positionless ones. Both are
gone: delimiters now take the span of what they enclose, so the stream is
emitted in non-decreasing position order and every token carries a real
position.
Non-decreasing, not strictly increasing. A block delimiter has no characters of
its own, so it shares its column with the token that does own the text there:
the opener with the first token inside, the closer with the last. Appended
naively that makes a zero-width run followed by one painting its neighbour as
punctuation — `- b` and `ok: true` would render their value as a delimiter.
addSpan now collapses same-column runs, and the token with characters wins.
Neither first-wins nor last-wins would do, because the opener precedes its
neighbour while the closer follows it.
Verified over the 283 golden specs in both renders, ~97k tokens: no positionless
token, no backwards step, and every same-position pair involves a delimiter —
two content tokens never collide. The pointer and $ref indexes built from those
documents are byte-identical before and after the upgrade, so only the spans
moved.
Visible effect: YAML separator colouring becomes uniform. It had been accidental
— the borrowed positions punctuation-coloured the ":" of a mapping's first entry
and the "-" of a sequence's first item, and nothing else. The YAML lexer elides
separator tokens by design, so ":" and "-" now take the preceding run's class
everywhere. The spec pane's JSON render is unaffected: its lexer emits real
delimiter tokens at real columns and never collided.
Also brings the `go` directive back to 1.25.0 across the workspace. It had been
raised to a PATCH release because core/json declared one; core no longer does,
and go-openapi does not require patch versions. The job C note in the
toolchain-independence workflow named the value explicitly and is reworded to
stop naming a patch at all — it had already gone stale once for this reason.
Note for other core consumers: `go get` raises the `go` directive from the
PRE-upgrade graph, so upgrading away from core/json v0.0.2 re-applies the 1.25.8
floor one last time. It has to be set back by hand afterwards.
Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
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.
The spec pane lays the lexer's tokens out by position to colour them. Two workarounds stood between it and the YAML lexer, both now fixed upstream in go-openapi/core v0.0.3.
A YAML block collection has no "{" / "[" / "}" / "]" character, so the lexer had nothing to point its container delimiters at. It reported the opener at the first entry's separator — a line BELOW the key it precedes — and the closer at line 0 column 0, which is not a position at all. The accumulator therefore had to sort each line's runs by column and drop the positionless ones. Both are gone: delimiters now take the span of what they enclose, so the stream is emitted in non-decreasing position order and every token carries a real position.
Non-decreasing, not strictly increasing. A block delimiter has no characters of its own, so it shares its column with the token that does own the text there: the opener with the first token inside, the closer with the last. Appended naively that makes a zero-width run followed by one painting its neighbour as punctuation —
- bandok: truewould render their value as a delimiter. addSpan now collapses same-column runs, and the token with characters wins. Neither first-wins nor last-wins would do, because the opener precedes its neighbour while the closer follows it.Verified over the 283 golden specs in both renders, ~97k tokens: no positionless token, no backwards step, and every same-position pair involves a delimiter — two content tokens never collide. The pointer and $ref indexes built from those documents are byte-identical before and after the upgrade, so only the spans moved.
Visible effect: YAML separator colouring becomes uniform. It had been accidental — the borrowed positions punctuation-coloured the ":" of a mapping's first entry and the "-" of a sequence's first item, and nothing else. The YAML lexer elides separator tokens by design, so ":" and "-" now take the preceding run's class everywhere. The spec pane's JSON render is unaffected: its lexer emits real delimiter tokens at real columns and never collided.
Change type
Please select: 🆕 New feature or enhancement|🔧 Bug fix'|📃 Documentation update
Short description
Fixes
Full description
Checklist