File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
scalariform/src/main/scala/scalariform/formatter Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -448,6 +448,24 @@ trait ExprFormatter { self: HasFormattingPreferences with AnnotationFormatter wi
448
448
formatResult ++= format(body)(bodyFormatterState)
449
449
450
450
// TODO: Simplified version of elseClause formatting
451
+ for (CatchClause (catchToken, catchBlockOrExpr) ← catchClauseOption) {
452
+ if (formattingPreferences(CompactControlReadability ) && bodyIsABlock && containsNewline(body))
453
+ formatResult = formatResult.before(catchToken, formatterState.currentIndentLevelInstruction)
454
+ else if (hiddenPredecessors(catchToken).containsNewline && ! (bodyIsABlock && containsNewline(body)))
455
+ formatResult = formatResult.before(catchToken, formatterState.currentIndentLevelInstruction)
456
+
457
+ catchBlockOrExpr match {
458
+ case Left (catchBlock) ⇒
459
+ formatResult = formatResult.before(catchBlock.firstToken, CompactEnsuringGap )
460
+ formatResult ++= format(catchBlock)
461
+ case Right (catchExpr) ⇒
462
+ val indentCatchExpr = hiddenPredecessors(catchExpr.firstToken).containsNewline
463
+ val instruction = if (indentCatchExpr) formatterState.nextIndentLevelInstruction else CompactEnsuringGap
464
+ formatResult = formatResult.before(catchExpr.firstToken, instruction)
465
+ val catchExprFormatterState = if (indentCatchExpr) formatterState.indent else formatterState
466
+ formatResult ++= format(catchExpr)(catchExprFormatterState)
467
+ }
468
+ }
451
469
452
470
// TODO: See elseClause formatting
453
471
for ((finallyToken, finallyBody) ← finallyClauseOption) {
You can’t perform that action at this time.
0 commit comments