@@ -307,11 +307,6 @@ object Scanners {
307307 */
308308 var currentRegion : Region = Outermost
309309
310- def currentIndentWidth : IndentWidth = currentRegion match {
311- case r : Indented => r.width
312- case _ => IndentWidth .Zero
313- }
314-
315310 /** The end marker that was skipped last */
316311 val endMarkers = new mutable.ListBuffer [EndMarker ]
317312
@@ -416,7 +411,7 @@ object Scanners {
416411 * value at the end of the endMarkers queue.
417412 */
418413 private def handleEndMarkers (width : IndentWidth ): Unit = {
419- if (next.token == IDENTIFIER && next.name == nme.end && width == currentIndentWidth ) {
414+ if (next.token == IDENTIFIER && next.name == nme.end && width == currentRegion.indentWidth ) {
420415 val lookahead = lookaheadScanner
421416 lookahead.nextToken() // skip the `end`
422417
@@ -589,15 +584,14 @@ object Scanners {
589584 insert(if (pastBlankLine) NEWLINES else NEWLINE , lineOffset)
590585 else if (indentIsSignificant) {
591586 if (nextWidth < lastWidth
592- || nextWidth == lastWidth && (indentPrefix == MATCH || indentPrefix == CATCH ) && token != CASE ) {
587+ || nextWidth == lastWidth && (indentPrefix == MATCH || indentPrefix == CATCH ) && token != CASE )
593588 currentRegion match {
594589 case r : Indented if ! r.isOutermost && ! isLeadingInfixOperator() =>
595590 currentRegion = r.enclosing
596591 insert(OUTDENT , offset)
597592 handleEndMarkers(nextWidth)
598593 case _ =>
599594 }
600- }
601595 else if (lastWidth < nextWidth ||
602596 lastWidth == nextWidth && (lastToken == MATCH || lastToken == CATCH ) && token == CASE ) {
603597 if (canStartIndentTokens.contains(lastToken)) {
@@ -1369,16 +1363,21 @@ object Scanners {
13691363 def outer : Region | Null
13701364 def isOutermost = outer == null
13711365 def enclosing : Region = outer.asInstanceOf [Region ]
1366+ def indentWidth = IndentWidth .Zero
13721367 }
1373- case class InParens (prefix : Token , outer : Region ) extends Region
1374- case class InBraces (var width : IndentWidth | Null , outer : Region ) extends Region
13751368 case class InString (multiLine : Boolean , outer : Region ) extends Region
1369+ case class InParens (prefix : Token , outer : Region ) extends Region
1370+ case class InBraces (var width : IndentWidth | Null , outer : Region ) extends Region {
1371+ override def indentWidth = width
1372+ }
13761373
13771374 /** A class describing an indentation region.
13781375 * @param width The principal indendation width
13791376 * @param others Other indendation widths > width of lines in the same region
13801377 */
1381- case class Indented (width : IndentWidth , others : Set [IndentWidth ], prefix : Token , outer : Region | Null ) extends Region
1378+ case class Indented (width : IndentWidth , others : Set [IndentWidth ], prefix : Token , outer : Region | Null ) extends Region {
1379+ override def indentWidth = width
1380+ }
13821381
13831382 val Outermost = Indented (IndentWidth .Zero , Set (), EMPTY , null )
13841383
0 commit comments