fix(highlight): parse yaml diff fragments per indentation segment - #29
Merged
Conversation
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>
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.
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
ERRORnode with zero captures — verified against the real grammar.yamlFragmentRowssplits 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.highlightGotmplreuses it for the masked yaml pass, since template fragments have the same failure mode.Tested
gpus/gpuClassNamemust get.pt-property— fails on main, passes here.grammars/markdown/local/rendersuites green; probed the reporter's actualgpu.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).