I find it quite frustrating that SwiftFormat deletes comments without warning. I understand that in certain cases there's no other way to consistently apply a reformatting rule without these deletions, but I hope it can be changed to at least give a warning about this first or maybe prevent comment deletions through some options. So far I got a quite significant amount of documentation comments lost because of SwiftFormat.
Steps to reproduce:
mkdir test
cd test
echo 'if true {\n}\n// comment\nelse {\n}' > test.swift
swiftformat .
cat test.swift
Expected result: // comment is not removed from code.
Actual result: // comment is lost after formatting without any warning and if true {} else {} result is printed as an output of cat.
@maxdesiatov this is absolutely a bug, not a deliberate design decision. Thanks for reporting it.
@MaxDesiatov fixed in 0.37.3
fantastic, thank you @nicklockwood!