travisjeffery / ClangFormat-Xcode

Xcode plug-in to to use clang-format from in Xcode and consistently format your code with Clang
https://twitter.com/travisjeffery
MIT License
2.89k stars 288 forks source link

Bundled clang-format issue with long Objecttive-C lines #81

Open kwasimensah opened 9 years ago

kwasimensah commented 9 years ago

I'm using a custom clang_format equivalent to -style="{BasedOnStyle: google, ContinuationIndentWidth: 4, ColumnLimit: 100, DerivePointerAlignment: false, PointerAlignment: Right, UseTab: Never}"

Using ClangFormat-Xcode with the bundled clang-format turns

-(BOOL)reallyLongFunctionName012345678901234567890123456789012345678:(ReallyLongTypeName012345678901234 *)vc{return NO;}

into

- (BOOL)reallyLongFunctionName012345678901234567890123456789012345678:
        (ReallyLongTypeName012345678901234 *)vc{
    return NO;
}

(there's an 4 extra spaces in front of (ReallyLongTypeName012345678901234 *)) Using the system version of clang-format (version 3.7.0) installed from homebrew does the right spacing:

echo "-(BOOL)reallyLongFunctionName012345678901234567890123456789012345678:(ReallyLongTypeName012345678901234 *)vc{return NO;}" | clang-format -style="{BasedOnStyle: google, ContinuationIndentWidth: 4, ColumnLimit: 100, DerivePointerAlignment: false, PointerAlignment: Right, UseTab: Never}"

returns

- (BOOL)reallyLongFunctionName012345678901234567890123456789012345678:
    (ReallyLongTypeName012345678901234 *)vc {
  return NO;
}
jshier commented 9 years ago

I'm seeing this too, see my Stack Overflow question here: http://stackoverflow.com/questions/30110479/clang-format-stop-breaking-long-methods-up Solution may be to revert the version of clang format included until this bug is fixed.

tonyarnold commented 9 years ago

I'll see if I can track down what's happening before reverting. It looks like someone has changed some pretty fundamental stuff with Objective-C formatting without testing properly.

tobihagemann commented 9 years ago

I'm not sure if this is related to OP's issue, but I'm having the same issue as @jshier. Setting ColumnLimit to 0 was fine a while ago (not sure if it was really introduced with clang-format 3.7), but now this setting behaves differently. I don't want my methods with multiple parameters to break into multiple lines (that line up with the colons.

What I actually don't understand (maybe this has to do something with Alcatraz?): I'm unable to revert to an older version so I'm stuck with this error for now. I'm replacing the folder at ~/Library/Application Support/Alcatraz/Plug-ins/ClangFormat. Isn't that sufficient? Is that the wrong location?

tonyarnold commented 9 years ago

@MuscleRumble I believe Alcatraz silently upgrades your plugins when you open Xcode.

You should try putting the older version of the clang-format binary in your path, and telling ClangFormat-Xcode to use the system bundled version of clang-format.

tobihagemann commented 9 years ago

Alriiight! Thanks! That works! :)

shams-ahmed commented 8 years ago

any update on this issue?

iSevenDays commented 8 years ago

any update?

jcislinsky commented 8 years ago

+1

mmcdole commented 8 years ago

Any word on this? Does a bug need to be filed upstream?

tonyarnold commented 8 years ago

Yeah, if you're game to compile from source the TOT Clang 3.8.0 version of clang-format seems better. ColumnLimit: 0 is broken as hell, but setting it to a really high number works well (it didn't before).