Index: lib/Format/UnwrappedLineFormatter.cpp =================================================================== --- lib/Format/UnwrappedLineFormatter.cpp +++ lib/Format/UnwrappedLineFormatter.cpp @@ -1092,7 +1092,7 @@ // unless the current \c AnnotatedLine is not at the beginning of a line. bool StartsNewLine = TheLine.First->NewlinesBefore > 0 || TheLine.First->IsFirst; - if (StartsNewLine) + if (TheLine.Affected && StartsNewLine) IndentTracker.adjustToUnmodifiedLine(TheLine); if (!DryRun) { bool ReformatLeadingWhitespace = Index: test/Format/line-ranges-indent.cpp =================================================================== --- /dev/null +++ test/Format/line-ranges-indent.cpp @@ -0,0 +1,13 @@ +// RUN: grep -Ev "// *[A-Z-]+:" %s \ +// RUN: | clang-format -style=LLVM -lines=3:3 \ +// RUN: | FileCheck -strict-whitespace %s +// CHECK: {{^\@protocol\ A$}} +@protocol A +// CHECK: {{^\ \@optional$}} + @optional +// CHECK: {{^//\ comment$}} +// comment +// CHECK: {{^-\ \(void\)f;$}} +- (void)f; +// CHECK: {{^\@end$}} +@end