Skip to content

fix(highlight): parse yaml diff fragments per indentation segment - #29

Merged
danilrwx merged 1 commit into
mainfrom
fix/yaml-fragment-highlight
Aug 11, 2026
Merged

fix(highlight): parse yaml diff fragments per indentation segment#29
danilrwx merged 1 commit into
mainfrom
fix/yaml-fragment-highlight

Conversation

@danilrwx

Copy link
Copy Markdown
Owner

What

Reported as "highlighting breaks on a local file", reproduced on any host: in a yaml hunk from deep inside a document (a CRD, in the report), every line from the first dedent renders plain.

tree-sitter-yaml roots the document at the first line's indent; a dedent below it (e.g. context at column 22, then an added sibling key at column 16) makes the rest of the reconstructed side one ERROR node with zero captures — verified against the real grammar.

yamlFragmentRows splits the side into maximal line runs that never dedent below their opening indent, parses each as its own document and merges the rows by offset. An ordinary full-file side is a single segment — exactly one parse, byte-for-byte the old behaviour. highlightGotmpl reuses it for the masked yaml pass, since template fragments have the same failure mode.

Tested

  • e2e fixture with the failing shape (context at col 22, added block at col 16): gpus/gpuClassName must get .pt-property — fails on main, passes here.
  • grammars/markdown/local/render suites green; probed the reporter's actual gpu.patch: the CRD file now highlights past the dedent.

The markdown half of the report does not reproduce on main — fences and code spans highlight correctly; that part was likely the store build (v1.3.0).

A hunk that starts deep inside a yaml document roots the parse at its
first line's indent, so the first dedent below it (a sibling key from an
outer level) turns the rest of the side into one ERROR node and every
line after it renders plain. Split the side text into maximal runs that
never dedent below their opening indent, parse each as its own document
and shift the rows back. A full file is one segment — one parse, as
before. The gotmpl path reuses it for its masked yaml pass.

Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
@github-actions github-actions Bot added the fix Bug fix (fix:) label Aug 11, 2026
@danilrwx danilrwx added this to the v1.4.0 milestone Aug 11, 2026
@danilrwx
danilrwx merged commit 3cb6356 into main Aug 11, 2026
4 checks passed
@danilrwx
danilrwx deleted the fix/yaml-fragment-highlight branch August 11, 2026 06:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Bug fix (fix:)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant