@@ -300,6 +300,7 @@ object Scanners {
300
300
while ! atStop do
301
301
nextToken()
302
302
// println(s"\nSTOP SKIP AT ${sourcePos().line + 1}, $this in $currentRegion")
303
+ if token == OUTDENT then dropUntil(_.isInstanceOf [Indented ])
303
304
skipping = false
304
305
305
306
// Get next token ------------------------------------------------------------
@@ -332,14 +333,8 @@ object Scanners {
332
333
result
333
334
334
335
private inline def dropUntil (inline matches : Region => Boolean ): Unit =
335
- while
336
- ! currentRegion.isOutermost
337
- && {
338
- val isLast = matches(currentRegion)
339
- currentRegion = currentRegion.enclosing
340
- ! isLast
341
- }
342
- do ()
336
+ while ! matches(currentRegion) && ! currentRegion.isOutermost do
337
+ currentRegion = currentRegion.enclosing
343
338
344
339
def adjustSepRegions (lastToken : Token ): Unit = (lastToken : @ switch) match {
345
340
case LPAREN | LBRACKET =>
@@ -348,6 +343,7 @@ object Scanners {
348
343
currentRegion = InBraces (currentRegion)
349
344
case RBRACE =>
350
345
dropUntil(_.isInstanceOf [InBraces ])
346
+ if ! currentRegion.isOutermost then currentRegion = currentRegion.enclosing
351
347
case RPAREN | RBRACKET =>
352
348
currentRegion match {
353
349
case InParens (prefix, outer) if prefix + 1 == lastToken => currentRegion = outer
@@ -356,9 +352,7 @@ object Scanners {
356
352
case OUTDENT =>
357
353
currentRegion match
358
354
case r : Indented => currentRegion = r.enclosing
359
- case r =>
360
- if skipping && r.enclosing.isClosedByUndentAt(indentWidth(offset)) then
361
- dropUntil(_.isInstanceOf [Indented ])
355
+ case _ =>
362
356
case STRINGLIT =>
363
357
currentRegion match {
364
358
case InString (_, outer) => currentRegion = outer
@@ -597,11 +591,12 @@ object Scanners {
597
591
i """ The start of this line does not match any of the previous indentation widths.
598
592
|Indentation width of current line : $nextWidth
599
593
|This falls between previous widths: ${ir.width} and $lastWidth""" ))
600
- case r : InBraces if ! closingRegionTokens.contains(token) && ! skipping =>
601
- report.warning(" Line is indented too far to the left, or a `}` is missing" , sourcePos())
602
594
case r =>
603
- if skipping && r.enclosing.isClosedByUndentAt(nextWidth) then
604
- insert(OUTDENT , offset)
595
+ if skipping then
596
+ if r.enclosing.isClosedByUndentAt(nextWidth) then
597
+ insert(OUTDENT , offset)
598
+ else if r.isInstanceOf [InBraces ] && ! closingRegionTokens.contains(token) then
599
+ report.warning(" Line is indented too far to the left, or a `}` is missing" , sourcePos())
605
600
606
601
else if lastWidth < nextWidth
607
602
|| lastWidth == nextWidth && (lastToken == MATCH || lastToken == CATCH ) && token == CASE then
0 commit comments