Skip to content

Commit fd06bfc

Browse files
committed
Removed unneeded newlines from parsed comments
Newlines from comments separated by lines are retained when comments are appended, so adding a newline between separate comments for a node is not needed.
1 parent 4d23492 commit fd06bfc

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

src/lib_json/json_reader.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,8 +358,6 @@ Reader::addComment(Location begin, Location end, CommentPlacement placement) {
358358
assert(lastValue_ != 0);
359359
lastValue_->setComment(std::string(begin, end), placement);
360360
} else {
361-
if (!commentsBefore_.empty())
362-
commentsBefore_ += "\n";
363361
commentsBefore_ += std::string(begin, end);
364362
}
365363
}

test/data/test_comment_02.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
},
1010
// C++-style comment
1111
"cpp-test" : {
12-
// Internal comment cpp-style
12+
// Multiline comment cpp-style
13+
// Second line
1314
"c" : 3,
1415
"d" : 4
1516
}

0 commit comments

Comments
 (0)