Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uncrustify: nested block indeting is wrong

I have this code:

dispatch_async(dispatch_get_main_queue(), ^{
    if (self.adAppearBlockIsAnimated) {
        [UIView animateWithDuration:kAnimationTime animations:^{
            self.adAppearBlock();
        }];
    }
});

Unfortunately, Uncrustify makes it look like:

dispatch_async(dispatch_get_main_queue(), ^{
    if (self.adAppearBlockIsAnimated) {
        [UIView animateWithDuration:kAnimationTime animations:^{
                self.adAppearBlock();
            }];
    }
});

My config:

indent_oc_block=true
indent_oc_block_msg = 0

Does anyone know how to make it look normal? Without extra spaces in nested block.

EDIT: I cannot comment now, I am using xCode.

like image 745
Michał Hernas Avatar asked Nov 13 '22 05:11

Michał Hernas


1 Answers

It appears that this a bug in Uncrustify itself; you can't necessarily work around it with a config change.

See:

https://github.com/bengardner/uncrustify/issues/68

(Personally, I'm a big fan of turning on "tab always indents", then selecting all, hitting and living with whatever Xcode produces. By having a standard set of formatting defaults for our team, anyone on the team can do this and not generate a bunch of spurious diffs when committing code.)

like image 90
bbum Avatar answered Nov 15 '22 07:11

bbum