Repository navigation
fix: broken syntax highlighting - #36
Merged
Merged
Conversation
tzabbi
force-pushed
the
fix/broken-syntax-highlighting
branch
from
October 10, 2026 16:17
0f582a1 to
45be107
Compare
|
So glad this was fixed! Looking forward to the next release :) |
|
Just updated Zed to |
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.
Summary
Fixes #35. Restores
(#set! "combined")inlanguages/helm/injections.scmso all(text)fragments are injected as one YAML document again, like in v0.0.6.With this fix:

Without this fix:

Root cause
Since v0.0.7 (commit 5095657, "Inject YAML per text node instead of combined", shipped with #32), YAML is injected into each
(text)node separately. The helm grammar splits the file at every{{ … }}action, so each fragment between two actions was parsed as its own standalone YAML document, with no knowledge of the indentation context around it.That breaks as soon as a
{{ … }}sits inside a deeply nested block and the YAML after it dedents. Fromtests/fixtures/networkpolicy.yaml:As a standalone document this fragment is invalid YAML.
tree-sitter-yamlproduces anERRORnode forpodSelector … "true"and drops the rest of the fragment, so roughly lines 21–38 (bothports:blocks and the second and third- from:entries) lose YAML highlighting entirely. Highlighting comes back after the next{{ … }}, because that fragment happens to start at a valid indentation again.Reproduced outside of Zed by parsing the fixture with the vendored helm grammar and
tree-sitter-yaml:(text)nodes, noERRORERROR{{ … }}blanked (≈combined)ERRORThis is common in real charts: any
{{ … }}value in a nested mapping followed by a dedent triggers it.Why
combinedwas removed, and the trade-offcombinedwas dropped as a workaround for #22 / zed-industries/zed#57341. Zed'ssplice_included_rangesdiscards combined-injection ranges that only touch an edit, so typing next toemptyDir: {}could wipe YAML highlighting for the rest of the file. The commit right before the removal (a2d11d5) already noted that removingcombined"would stop YAML from stitching across{{ }}on load". That is exactly what #35 is.Bringing
combinedback means:{}, the rest of its line, and the trailing newline in one(text)node, which should make [bug] Empty YAML Mapping Breaks Syntax Highlighting #22 less likely than before. Adjacent ranges around{{ … }}can still touch, though.combinedis safe again.A YAML layer that is valid on load and occasionally dropped while editing seemed better to us than one that is wrong on load for a large share of real-world templates.
Testing
tests/fixtures/networkpolicy.yaml: highlighting is correct on open ([Bug] Syntax highlighting is broken #35)tests/fixtures/empty-mapping.yaml: type at EOL afteremptyDir: {}and check that YAML highlighting below survives ([bug] Empty YAML Mapping Breaks Syntax Highlighting #22)