DuckQueen
DuckQueen

Reputation: 802

How to set Clang-Format Style Options to keep no line break before catch?

So currently I use next style:

{ 
  BasedOnStyle: "LLVM", 
  IndentWidth: 4,   
  UseTab: false, 
  ColumnLimit: 150, 
  Standard: "Cpp11",
  BreakBeforeBraces: "Attach",  
  BreakBeforeBinaryOperators: false,    
  AlwaysBreakTemplateDeclarations: true, 
  AllowShortLoopsOnASingleLine: false,
  AllowShortIfStatementsOnASingleLine: false, 
  AllowAllParametersOfDeclarationOnNextLine: true, 
  SpacesInParentheses: true,    
  SpacesBeforeTrailingComments: 1, 
  SpaceInEmptyParentheses: false,
  SpaceAfterControlStatementKeyword: true, 
  PointerBindsToType: true, 
  MaxEmptyLinesToKeep: 1,
  IndentFunctionDeclarationAfterType: true, 
  IndentCaseLabels: true,
  ExperimentalAutoDetectBinPacking: true, 
  DerivePointerBinding: true, 
  Cpp11BracedListStyle: false, 
  ConstructorInitializerAllOnOneLineOrOnePerLine: true,
  BreakConstructorInitializersBeforeComma: true
}

and get

try {
}
 catch ( ... ) {
}

While I want to get

try {
} catch ( ... ) {
}

Can any one say which Clang-Format Style Option is responsible for such behaviour?

Upvotes: 3

Views: 3816

Answers (2)

djasper
djasper

Reputation: 2554

Support for try-catch-blocks has only been added recently. If you update to a current version, this should be fixed.

Upvotes: 1

griotspeak
griotspeak

Reputation: 13247

BreakBeforeBraces should, as I understand it, affect the behavior you are concerned with. Attach looks like the correct option from it description on the style options page that you referenced. The only reason that I can see for it not working is that BreakBeforeBraces expects a BraceBreakingStyle enum. Try it without the making Attach a string.

BreakBeforeBraces: Attach 

or

BreakBeforeBraces: BS_Attach 

Upvotes: 4

Related Questions