@@ -92,7 +92,7 @@ object Scanners {
92
92
|| token == IDENTIFIER && isOperatorPart(name(name.length - 1 ))
93
93
94
94
def isArrow =
95
- token == ARROW || token == CTXARROW || token == ARROWeol
95
+ token == ARROW || token == CTXARROW
96
96
}
97
97
98
98
abstract class ScannerCommon (source : SourceFile )(using Context ) extends CharArrayReader with TokenData {
@@ -612,11 +612,7 @@ object Scanners {
612
612
insert(if (pastBlankLine) NEWLINES else NEWLINE , lineOffset)
613
613
else if indentIsSignificant then
614
614
if nextWidth < lastWidth
615
- || nextWidth == lastWidth
616
- && indentPrefix.match
617
- case MATCH | CATCH => token != CASE
618
- case _ => false
619
- then
615
+ || nextWidth == lastWidth && (indentPrefix == MATCH || indentPrefix == CATCH ) && token != CASE then
620
616
if currentRegion.isOutermost then
621
617
if nextWidth < lastWidth then currentRegion = topLevelRegion(nextWidth)
622
618
else if ! isLeadingInfixOperator(nextWidth) && ! statCtdTokens.contains(lastToken) && lastToken != INDENT then
@@ -643,12 +639,7 @@ object Scanners {
643
639
else if r.isInstanceOf [InBraces ] && ! closingRegionTokens.contains(token) then
644
640
report.warning(" Line is indented too far to the left, or a `}` is missing" , sourcePos())
645
641
else if lastWidth < nextWidth
646
- || lastWidth == nextWidth
647
- && lastToken.match
648
- case MATCH | CATCH => token == CASE
649
- case ARROWeol => true
650
- case _ => false
651
- then
642
+ || lastWidth == nextWidth && (lastToken == MATCH || lastToken == CATCH ) && token == CASE then
652
643
if canStartIndentTokens.contains(lastToken) then
653
644
currentRegion = Indented (nextWidth, lastToken, currentRegion)
654
645
insert(INDENT , offset)
@@ -680,12 +671,19 @@ object Scanners {
680
671
reset()
681
672
if atEOL then token = COLONeol
682
673
683
- def observeArrowEOL (): Unit =
684
- if indentSyntax && token == ARROW then
674
+ // consume => and insert <indent> if applicable
675
+ def observeArrowIndented (): Unit =
676
+ if isArrow && indentSyntax then
685
677
peekAhead()
686
678
val atEOL = isAfterLineEnd || token == EOF
687
679
reset()
688
- if atEOL then token = ARROWeol
680
+ if atEOL then
681
+ val nextWidth = indentWidth(next.offset)
682
+ val lastWidth = currentRegion.indentWidth
683
+ if lastWidth < nextWidth then
684
+ currentRegion = Indented (nextWidth, COLONeol , currentRegion)
685
+ offset = next.offset
686
+ token = INDENT
689
687
690
688
def observeIndented (): Unit =
691
689
if indentSyntax && isNewLine then
0 commit comments