CrossProduct
CrossProduct

Reputation: 131

Blank line after curly brace in function with uncrustify

I have configured xcode to use Uncrustify to beautify the code. I modified the Uncrustify configuration file and the resulting code is almost as desired.

One thing I don't like is the removal of a blank line between a closing curly brace and the next line of code. For example, this is what Uncrustify currently does:

Input:

if (jsonData != NULL)
{
    return [jsonData objectFromJSONData];
}

NSLog(@"Data read");

Current output:

if (jsonData != NULL)
{
    return [jsonData objectFromJSONData];
}
NSLog(@"Data read");

The desired output would be, in this case, the same as the input:

if (jsonData != NULL)
{
    return [jsonData objectFromJSONData];
}

NSLog(@"Data read");

I already played around with nl_after_func_body = true but this doesn't help.


I now managed to get the behaviour I wanted using the following addition to the configuration file:

nl_before_if = force
nl_after_if = force
nl_before_for = force
nl_after_for = force
nl_before_while = force
nl_after_while = force
nl_before_switch = force
nl_after_switch = force
nl_before_do = force
nl_after_do = force

Upvotes: 4

Views: 1774

Answers (2)

Pablo Oliva
Pablo Oliva

Reputation: 354

Try using

nl_after_if = add   # ignore/add/remove/force

In your config.

Inspired by: Blank line after curly brace in function with uncrustify

Upvotes: 0

Pål Brattberg
Pål Brattberg

Reputation: 4698

Try this:

 nl_after_func_body = 2

Upvotes: 1

Related Questions