Support same-column sequence indentation in YAML#7135
Open
Jenson3210 wants to merge 4 commits intomainfrom
Open
Support same-column sequence indentation in YAML#7135Jenson3210 wants to merge 4 commits intomainfrom
Jenson3210 wants to merge 4 commits intomainfrom
Conversation
Adds `indentedSequences` property to `IndentsStyle` to distinguish between indented (` - item`) and same-column (`- item`) sequence styles. Autodetection compares sequence entry indent with parent mapping entry indent to determine the style in use. Fixes #7125
Main added handling for dash-on-own-line (multiline firstIndent) in the lastIndent computation. Resolved by combining both: use dashColumn (which accounts for same-column vs indented style) in the new linebreak/non-linebreak branching from main.
Member
Contributor
Author
|
no, AFAICS @greg-at-moderne changed the indentation after the hyphen. In a yaml: |
timtebeek
approved these changes
Mar 27, 2026
Member
timtebeek
left a comment
There was a problem hiding this comment.
Great to see this properly fixed, thanks!
If I'm not mistaken then any changes to style classes require a coordinated roll out, right?
Contributor
Author
|
Good to see you watching out. Will make some changes to be safer and only work when it really exists but not crash when not. |
3 tasks
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
Adds
indentedSequencesboolean toIndentsStyleto distinguish between indented style (- item) and same-column style (- itemat parent key column)Extends
Autodetectto detect which sequence indentation style a document uses by comparing sequence entry indent with parent mapping entry indentUpdates
IndentsVisitorto respect the detected style, placing dashes at the correct column and computinglastIndentso sibling mapping entries align properlyFixes IndentsVisitor does not support same-column sequence indentation style #7125
Test plan
IndentsTesttests pass (no regressions for indented style)SameColumnSequenceIndentnested test class: basic indent correction, preservation of correct indent, nested mappings, multiple entries, mixed-type sequencesAutodetectTest: detects indented style, detects same-column style, defaults to indented when no sequences presentrewrite-yamltest suite passes