Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: MergeYaml block indentation not as expected #4358

Merged
merged 25 commits into from
Nov 25, 2024
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
cleanup
pstreef authored and jevanlingen committed Nov 25, 2024
commit f7fecf999177c0e2b3ea62104a49c9b592dcdd69
Original file line number Diff line number Diff line change
@@ -191,7 +191,7 @@ private Yaml.Documents parseFromInput(Path sourceFile, EncodingDetectingInputStr
lastEnd = event.getEndMark().getIndex();
}
blockStack.push(new MappingBuilder(fmt, startBracePrefix, anchor));
currentIndent = countIndent(fmt);
currentIndent = countLeadingSpaces(fmt);
break;
}
case Scalar: {
@@ -352,7 +352,7 @@ private Yaml.Documents parseFromInput(Path sourceFile, EncodingDetectingInputStr
lastEnd--;
}
blockStack.push(new SequenceBuilder(fmt, startBracketPrefix, anchor));
currentIndent = countIndent(fmt);
currentIndent = countLeadingSpaces(fmt);
break;
}
case Alias: {
@@ -639,7 +639,8 @@ public Yaml.Mapping visitMapping(Yaml.Mapping mapping, Integer p) {
}.visit(y, 0);
}

private int countIndent(String line) {
//Note: the SnakeYaml parser will complain on any tab indentation, so this should suffice.
private int countLeadingSpaces(String line) {
int count = 0;
for (int i = 0; i < line.length(); i++) {
if (line.charAt(i) == ' ') {