SwiftFormat deletes comments without warning

Created on 4 Jan 2019  路  3Comments  路  Source: nicklockwood/SwiftFormat

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.

All 3 comments

@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!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AniHovhannisyanAni picture AniHovhannisyanAni  路  3Comments

sebastianfrelle picture sebastianfrelle  路  4Comments

mdiep picture mdiep  路  3Comments

meherkasam picture meherkasam  路  4Comments

Cyberbeni picture Cyberbeni  路  4Comments