@@ -470,16 +470,15 @@ object Scanners {
470470 else if indentIsSignificant then
471471 if nextWidth < lastWidth
472472 || nextWidth == lastWidth && (indentPrefix == MATCH || indentPrefix == CATCH ) && token != CASE then
473- if ! currentRegion.isOutermost &&
474- ! isLeadingInfixOperator() &&
475- ! statCtdTokens.contains(lastToken) then
473+ if currentRegion.isOutermost then
474+ if nextWidth < lastWidth then currentRegion = topLevelRegion(nextWidth)
475+ else if ! isLeadingInfixOperator() && ! statCtdTokens.contains(lastToken) then
476476 currentRegion match
477477 case r : Indented =>
478478 currentRegion = r.enclosing
479479 insert(OUTDENT , offset)
480480 case r : InBraces if ! closingRegionTokens.contains(token) =>
481- report.warning(" Line is indented too far to the left, or a `}` is missing" ,
482- source.atSpan(Span (offset)))
481+ report.warning(" Line is indented too far to the left, or a `}` is missing" , sourcePos())
483482 case _ =>
484483
485484 else if lastWidth < nextWidth
@@ -1318,7 +1317,7 @@ object Scanners {
13181317 /* Initialization: read first char, then first token */
13191318 nextChar()
13201319 nextToken()
1321- currentRegion = Indented (indentWidth(offset), Set (), EMPTY , null )
1320+ currentRegion = topLevelRegion (indentWidth(offset))
13221321 }
13231322 // end Scanner
13241323
@@ -1359,6 +1358,8 @@ object Scanners {
13591358 case class Indented (width : IndentWidth , others : Set [IndentWidth ], prefix : Token , outer : Region | Null ) extends Region :
13601359 knownWidth = width
13611360
1361+ def topLevelRegion (width : IndentWidth ) = Indented (width, Set (), EMPTY , null )
1362+
13621363 enum IndentWidth {
13631364 case Run (ch : Char , n : Int )
13641365 case Conc (l : IndentWidth , r : Run )
0 commit comments