Skip to content

Commit

Permalink
Minor fix: added multiline scalar condition back into YamlParser with…
Browse files Browse the repository at this point in the history
… test. (#3633)

fixes #3632
  • Loading branch information
traceyyoshima authored Oct 18, 2023
1 parent fcfe473 commit 0b56a1d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,9 @@ private Yaml.Documents parseFromInput(Path sourceFile, EncodingDetectingInputStr
case PLAIN:
default:
style = Yaml.Scalar.Style.PLAIN;
if (!scalarValue.startsWith("@") && event.getStartMark().getIndex() >= reader.getBufferIndex()) {
scalarValue = reader.readStringFromBuffer(event.getStartMark().getIndex(), event.getEndMark().getIndex() - 1);
}
break;
}
BlockBuilder builder = blockStack.isEmpty() ? null : blockStack.peek();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,20 @@ void suffixBeforeColon() {
);
}

@Issue("https://github.com/openrewrite/rewrite/issues/3632")
@Test
void multilineScalar() {
rewriteRun(
yaml(
"""
data: &anc |
@this is a long string@
bar: *anc
"""
)
);
}

@Test
void literals() {
rewriteRun(
Expand Down

0 comments on commit 0b56a1d

Please sign in to comment.