Skip to content

fix(tui): pin swift highlights query to the pinned parser version - #63165

Open
delaysystem wants to merge 1 commit into
anomalyco:devfrom
delaysystem:delaysystem/swift-highlights-pin-62867
Open

delaysystem wants to merge 1 commit into
anomalyco:devfrom
delaysystem:delaysystem/swift-highlights-pin-62867

Conversation

@delaysystem

@delaysystem delaysystem commented Nov 10, 2026 •

Copy link
Copy Markdown

Issue for this PR

Closes #62867

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Swift fenced blocks render as plain text because the highlights query floats on main while the wasm parser is pinned to 0.7.1. The main query references nodes the old grammar does not know (nil_literal, unsafe_expression), so the query fails to compile. I verified against the real 0.7.1 wasm: the main query fails with Bad node name 'unsafe_expression', the 0.7.1 query compiles and yields captures.

This pins the query URL to 0.7.1, the same version as the wasm. It is a port of #49482, which fixed this on V1 and was closed only because V1 stopped taking PRs.

How did you verify your code works?

New case in test/util/filetype.test.ts asserting the highlights URL tracks the pinned wasm version (fails on the main URL, passes on the pin). bun run test test/util/filetype.test.ts: 4 pass. tsc -b clean. Also ran the real 0.7.1 Swift wasm against both queries directly.

Visual

<svg xmlns="http://www.w3.org/2000/svg" width="240" height="72" viewBox="0 0 240 72">
  <rect x="8" y="8" width="224" height="56" rx="6" fill="currentColor" opacity="0.08"/>
  <rect x="20" y="20" width="60" height="8" rx="4" fill="currentColor" opacity="0.25"/>
  <rect x="20" y="34" width="120" height="8" rx="4" fill="currentColor" opacity="0.25"/>
  <rect x="20" y="48" width="90" height="8" rx="4" fill="currentColor" opacity="0.25"/>
  <rect x="20" y="20" width="60" height="8" rx="4" fill="currentColor" opacity="0.9">
    <animate attributeName="opacity" values="0;0.9;0.9;0" keyTimes="0;0.25;0.75;1" dur="2.4s" repeatCount="indefinite"/>
  </rect>
  <rect x="20" y="34" width="44" height="8" rx="4" fill="currentColor" opacity="0.9">
    <animate attributeName="opacity" values="0;0.9;0.9;0" keyTimes="0;0.25;0.75;1" dur="2.4s" begin="0.3s" repeatCount="indefinite"/>
  </rect>
  <rect x="20" y="48" width="30" height="8" rx="4" fill="currentColor" opacity="0.9">
    <animate attributeName="opacity" values="0;0.9;0.9;0" keyTimes="0;0.25;0.75;1" dur="2.4s" begin="0.6s" repeatCount="indefinite"/>
  </rect>
</svg>

Screenshots / recordings

Not a UI change (TUI text rendering). Before/after screenshots are in the review thread below.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

The highlights query floated on main while the wasm parser is pinned to 0.7.1. The main query references nodes the old grammar does not know, so it fails to compile and swift renders plain. Pin the query to 0.7.1 and assert the query URL tracks the pinned wasm version.
@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Nov 10, 2026

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix works. I ran the #62867 reproduction from source: on the base the Swift block is plain text, and with this change it is highlighted like the TypeScript block (screenshots below). Against the real 0.7.1 Swift parser, the main highlights query fails to compile (Bad node name 'unsafe_expression'). The 0.7.1 query compiles, and so does the current nvim-treesitter locals query, so locals needs no change. The filetype tests pass and tsc -b is clean.

Public API: unchanged.

The only point is the added test, see the inline comment.

Before

After

expect(filetype("")).toBe("none")
})

test("pins the swift highlights query to the pinned parser version", () => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test only checks URL strings with a regex. It would not catch the real failure, a query that does not compile against the wasm, and for a one-line pin it adds more than the fix needs. I'd drop it so the change stays minimal.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This bug is the query drifting from the pinned wasm, so the test guards exactly that. Say the word and I'll drop it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair point: the test does fail if the Swift query goes back to a moving branch, and that is how this bug started. What it can't catch is a query that doesn't compile against the wasm, which was the actual failure here. It also only covers Swift. I'd still lean towards keeping this PR to the one-line pin, but it isn't blocking, so it's your call and the maintainers'. A test that compiles each parser's queries against its wasm would guard against drift properly, but that's separate work and belongs in its own PR.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Nov 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

This branch has not been deployed

No deployments
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.

tui: swift fenced code blocks are not syntax highlighted

1 participant