Skip to content

Commit

Permalink
Fix reading multiline strings with CRLF, set LF in tests to pass in W…
Browse files Browse the repository at this point in the history
…indows
  • Loading branch information
hevav committed Aug 30, 2023
1 parent 2599b10 commit e9d45f9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@

public abstract class AbstractWriter {

protected static final char NEW_LINE = '\n';

protected final SerializerConfig config;
protected final BufferedWriter writer;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,8 @@ private void writeCharacters(char[] characters, boolean escapeNewLine, boolean d
char highSurrogate = 0;
for (char character : characters) {
if (!escapeNewLine) {
if (character == lineSeparatorChars[lineSeparatorCharsCaught]) {
if (++lineSeparatorCharsCaught == lineSeparatorChars.length) {
if (character == AbstractWriter.NEW_LINE || character == lineSeparatorChars[lineSeparatorCharsCaught]) {
if (character == AbstractWriter.NEW_LINE || ++lineSeparatorCharsCaught == lineSeparatorChars.length) {
lineSeparatorCharsCaught = 0;
this.writeLineAndIndent();

Expand Down
2 changes: 1 addition & 1 deletion src/test/java/net/elytrium/serializer/SerializerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ public String serialize(String from) {
public String deserialize(String from) {
return from.trim().isEmpty() ? null : from;
}
}).registerSerializer(new PathSerializer()).setCommentValueIndent(1).build();
}).registerSerializer(new PathSerializer()).setCommentValueIndent(1).setLineSeparator("\n").build();

Settings() {
super(Settings.CONFIG);
Expand Down

0 comments on commit e9d45f9

Please sign in to comment.