Add a new clang-format style option ObjCBlockResetsIndent of type bool. It defaults to false.
When true, ObjC blocks resets indentation to that of its owner block.
The resetting behavior is often desirable, as it leaves more columns for the content of the ObjC block.
E.g. for an unformatted file test.m like this:
- (void)test { [self callAVeryVeryVeryVeryVeryVeryLongAsyncMethodWith:@"Some param" completionHandler:^() { [self callAnotherLongMethodHereWith:@"param"]; }]; } - (void)test2 { [self callAsychronousMethodWith:@"Some param" failureHandler:^() { [self handleFailure]; } successHandler:^() { [self handleSuccess]; }]; }
The formatted result with ObjCBlockResetsIndent=false (or omitted) is this:
// clang-format -style='{ObjCBlockResetsIndent: false}' test.m // OR // clang-format test.m - (void)test { [self callAVeryVeryVeryVeryVeryVeryLongAsyncMethodWith:@"Some param" completionHandler:^() { [self callAnotherLongMethodHereWith:@"param"]; }]; } - (void)test2 { [self callAsychronousMethodWith:@"Some param" failureHandler:^() { [self handleFailure]; } successHandler:^() { [self handleSuccess]; }]; }
The formatted result with ObjCBlockResetsIndent=true is this:
// clang-format -style='{ObjCBlockResetsIndent: true}' test.m - (void)test { [self callAVeryVeryVeryVeryVeryVeryLongAsyncMethodWith:@"Some param" completionHandler:^() { [self callAnotherLongMethodHereWith:@"param"]; }]; } - (void)test2 { [self callAsychronousMethodWith:@"Some param" failureHandler:^() { [self handleFailure]; } successHandler:^() { [self handleSuccess]; }]; }