8

clang-format とブロックに問題があります。後続ブロックを使用したメソッド呼び出しの次の形式を維持したいと思います。

[self presentViewController:alertController animated:YES completion:^{
    NSLog(@"Output");
    // Do something
}];

ColumnLimit を 0 に設定しました。これはどこでも機能しますが、ブロック内で何もフォーマットしないという副作用があります (if ステートメント、他の呼び出しなど)。ブロック内のコードをフォーマットする唯一の方法は、ColumnLimit を > 0 に設定することですが、100000 のような大きな値に設定しても、すべての引数にブレークが追加されます。これは望ましくありません。

[self presentViewController:alertController
               animated:YES
             completion:^{
                 NSLog(@"Output");
                 // Do something
             }];

したがって、私が望む組み合わせは、ブロック内のコードが適切にフォーマットされ、メソッド呼び出しについては何も触れないことです。

私のclang形式の設定:

Language: Cpp

ColumnLimit: 0
AllowShortBlocksOnASingleLine: false
AllowShortFunctionsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortLoopsOnASingleLine: false
KeepEmptyLinesAtTheStartOfBlocks: false
MaxEmptyLinesToKeep: 1
IndentWidth: 4
TabWidth: 4
UseTab: Never
PointerAlignment: Right
DerivePointerAlignment: false
ObjCSpaceAfterProperty: true
BreakBeforeBraces: Stroustrup
AllowShortIfStatementsOnASingleLine: false
BreakBeforeTernaryOperators: false
IndentCaseLabels: true
AllowShortCaseLabelsOnASingleLine: false
AlignTrailingComments: true
BinPackParameters: false
BinPackArguments: false
AllowShortFunctionsOnASingleLine: false
IndentWrappedFunctionNames: false
ObjCSpaceBeforeProtocolList: true
SpacesInParentheses: false
SpacesInAngles:  false
SpaceInEmptyParentheses: false
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: true
SpaceBeforeAssignmentOperators: true
SpacesBeforeTrailingComments: 1
ObjCBlockIndentWidth: 4

Clang 形式のバージョンは 3.6 です。

これが達成できるかどうかはわかりませんが、どんな助けも素晴らしいでしょう。

4

0 に答える 0