ClangFormat-Xcode icon indicating copy to clipboard operation
ClangFormat-Xcode copied to clipboard

Bundled clang-format issue with long Objecttive-C lines

Open kwasimensah opened this issue 9 years ago • 10 comments

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;
}

kwasimensah avatar Apr 14 '15 20:04 kwasimensah

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.

jshier avatar May 15 '15 19:05 jshier

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.

tonyarnold avatar May 18 '15 23:05 tonyarnold

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?

tobihagemann avatar May 22 '15 08:05 tobihagemann

@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.

tonyarnold avatar May 22 '15 08:05 tonyarnold

Alriiight! Thanks! That works! :)

tobihagemann avatar May 23 '15 14:05 tobihagemann

any update on this issue?

shams-ahmed avatar Jul 15 '15 09:07 shams-ahmed

any update?

iSevenDays avatar Sep 11 '15 09:09 iSevenDays

+1

jcislinsky avatar Nov 13 '15 06:11 jcislinsky

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

mmcdole avatar Jan 08 '16 20:01 mmcdole

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).

tonyarnold avatar Jan 09 '16 12:01 tonyarnold