Skip to content

fix(genspec-tui): drop the YAML position workarounds, upgrade core to v0.0.3 - #71

Merged
fredbi merged 1 commit into
go-openapi:masterfrom
fredbi:fix/simplify-yaml-parsing
Jul 31, 2026
Merged

fix(genspec-tui): drop the YAML position workarounds, upgrade core to v0.0.3#71
fredbi merged 1 commit into
go-openapi:masterfrom
fredbi:fix/simplify-yaml-parsing

Conversation

@fredbi

@fredbi fredbi commented Jul 31, 2026

Copy link
Copy Markdown
Member

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.

Change type

Please select: 🆕 New feature or enhancement|🔧 Bug fix'|📃 Documentation update

Short description

Fixes

Full description

Checklist

  • I have signed all my commits with my name and email (see DCO. This does not require a PGP-signed commit
  • I have rebased and squashed my work, so only one commit remains
  • I have added tests to cover my changes.
  • I have properly enriched go doc comments in code.
  • I have properly documented any breaking change.

… 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>
@fredbi
fredbi merged commit 1f5393a into go-openapi:master Jul 31, 2026
24 checks passed
@fredbi
fredbi deleted the fix/simplify-yaml-parsing branch July 31, 2026 19:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant