@@ -307,7 +307,7 @@ object Scanners {
307
307
var sepRegions : List [Token ] = Nil
308
308
309
309
/** Indentation widths, innermost to outermost */
310
- var indent : IndentRegion = IndentRegion (IndentWidth .Zero , Set (), null )
310
+ var indent : IndentRegion = IndentRegion (IndentWidth .Zero , Set (), EMPTY , null )
311
311
312
312
// Scala 2 compatibility
313
313
@@ -538,13 +538,15 @@ object Scanners {
538
538
! isLeadingInfixOperator())
539
539
insert(if (pastBlankLine) NEWLINES else NEWLINE , lineOffset)
540
540
else if (indentIsSignificant) {
541
- if (lastWidth < curWidth) {
541
+ if (lastWidth < curWidth ||
542
+ lastWidth == curWidth && (lastToken == MATCH || lastToken == CATCH ) && token == CASE ) {
542
543
if (canStartIndentTokens.contains(lastToken)) {
543
- indent = IndentRegion (curWidth, Set (), indent)
544
+ indent = IndentRegion (curWidth, Set (), lastToken, indent)
544
545
insert(INDENT , offset)
545
546
}
546
547
}
547
- else if (curWidth < lastWidth) {
548
+ else if (curWidth < lastWidth ||
549
+ curWidth == lastWidth && (indent.token == MATCH || indent.token == CATCH ) && token != CASE ) {
548
550
if (! isLeadingInfixOperator()) {
549
551
indent = indent.enclosing
550
552
insert(OUTDENT , offset)
@@ -564,7 +566,7 @@ object Scanners {
564
566
|This falls between previous widths: ${indent.width} and $lastWidth
565
567
|Sepregions = $sepRegions / ${getClass}""" )
566
568
else
567
- indent = IndentRegion (indent.width, indent.others + curWidth, indent.outer)
569
+ indent = IndentRegion (indent.width, indent.others + curWidth, indent.token, indent. outer)
568
570
}
569
571
}
570
572
@@ -1291,7 +1293,7 @@ object Scanners {
1291
1293
* @param width The principal indendation width
1292
1294
* @param others Other indendation widths > width of lines in the same region
1293
1295
*/
1294
- class IndentRegion (val width : IndentWidth , val others : Set [IndentWidth ], val outer : IndentRegion | Null ) {
1296
+ class IndentRegion (val width : IndentWidth , val others : Set [IndentWidth ], val token : Token , val outer : IndentRegion | Null ) {
1295
1297
def enclosing : IndentRegion = outer.asInstanceOf [IndentRegion ]
1296
1298
def isOutermost = outer == null
1297
1299
}
0 commit comments