Repository navigation
fix(tui): pin swift highlights query to the pinned parser version - #63165
delaysystem wants to merge 1 commit into
Conversation
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.
There was a problem hiding this comment.
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.
| expect(filetype("")).toBe("none") | ||
| }) | ||
|
|
||
| test("pins the swift highlights query to the pinned parser version", () => { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
This bug is the query drifting from the pinned wasm, so the test guards exactly that. Say the word and I'll drop it.
There was a problem hiding this comment.
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.
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |


Issue for this PR
Closes #62867
Type of change
What does this PR do?
Swift fenced blocks render as plain text because the highlights query floats on
mainwhile the wasm parser is pinned to0.7.1. Themainquery 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: themainquery fails withBad node name 'unsafe_expression', the0.7.1query 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.tsasserting the highlights URL tracks the pinned wasm version (fails on themainURL, passes on the pin).bun run test test/util/filetype.test.ts: 4 pass.tsc -bclean. Also ran the real 0.7.1 Swift wasm against both queries directly.Visual
Screenshots / recordings
Not a UI change (TUI text rendering). Before/after screenshots are in the review thread below.
Checklist