@@ -470,16 +470,15 @@ object Scanners {
470
470
else if indentIsSignificant then
471
471
if nextWidth < lastWidth
472
472
|| 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
476
476
currentRegion match
477
477
case r : Indented =>
478
478
currentRegion = r.enclosing
479
479
insert(OUTDENT , offset)
480
480
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())
483
482
case _ =>
484
483
485
484
else if lastWidth < nextWidth
@@ -1318,7 +1317,7 @@ object Scanners {
1318
1317
/* Initialization: read first char, then first token */
1319
1318
nextChar()
1320
1319
nextToken()
1321
- currentRegion = Indented (indentWidth(offset), Set (), EMPTY , null )
1320
+ currentRegion = topLevelRegion (indentWidth(offset))
1322
1321
}
1323
1322
// end Scanner
1324
1323
@@ -1359,6 +1358,8 @@ object Scanners {
1359
1358
case class Indented (width : IndentWidth , others : Set [IndentWidth ], prefix : Token , outer : Region | Null ) extends Region :
1360
1359
knownWidth = width
1361
1360
1361
+ def topLevelRegion (width : IndentWidth ) = Indented (width, Set (), EMPTY , null )
1362
+
1362
1363
enum IndentWidth {
1363
1364
case Run (ch : Char , n : Int )
1364
1365
case Conc (l : IndentWidth , r : Run )
0 commit comments