@@ -92,7 +92,7 @@ object Scanners {
9292 || token == IDENTIFIER && isOperatorPart(name(name.length - 1 ))
9393
9494 def isArrow =
95- token == ARROW || token == CTXARROW
95+ token == ARROW || token == CTXARROW || token == ARROWeol
9696 }
9797
9898 abstract class ScannerCommon (source : SourceFile )(using Context ) extends CharArrayReader with TokenData {
@@ -612,7 +612,11 @@ object Scanners {
612612 insert(if (pastBlankLine) NEWLINES else NEWLINE , lineOffset)
613613 else if indentIsSignificant then
614614 if nextWidth < lastWidth
615- || nextWidth == lastWidth && (indentPrefix == MATCH || indentPrefix == CATCH ) && token != CASE then
615+ || nextWidth == lastWidth
616+ && indentPrefix.match
617+ case MATCH | CATCH => token != CASE
618+ case _ => false
619+ then
616620 if currentRegion.isOutermost then
617621 if nextWidth < lastWidth then currentRegion = topLevelRegion(nextWidth)
618622 else if ! isLeadingInfixOperator(nextWidth) && ! statCtdTokens.contains(lastToken) && lastToken != INDENT then
@@ -637,9 +641,13 @@ object Scanners {
637641 insert(OUTDENT , offset)
638642 else if r.isInstanceOf [InBraces ] && ! closingRegionTokens.contains(token) then
639643 report.warning(" Line is indented too far to the left, or a `}` is missing" , sourcePos())
640-
641644 else if lastWidth < nextWidth
642- || lastWidth == nextWidth && (lastToken == MATCH || lastToken == CATCH ) && token == CASE then
645+ || lastWidth == nextWidth
646+ && lastToken.match
647+ case MATCH | CATCH => token == CASE
648+ case ARROWeol => true
649+ case _ => false
650+ then
643651 if canStartIndentTokens.contains(lastToken) then
644652 currentRegion = Indented (nextWidth, lastToken, currentRegion)
645653 insert(INDENT , offset)
@@ -657,7 +665,7 @@ object Scanners {
657665 def spaceTabMismatchMsg (lastWidth : IndentWidth , nextWidth : IndentWidth ): Message =
658666 em """ Incompatible combinations of tabs and spaces in indentation prefixes.
659667 |Previous indent : $lastWidth
660- |Latest indent : $nextWidth"""
668+ |Latest indent : $nextWidth"""
661669
662670 def observeColonEOL (inTemplate : Boolean ): Unit =
663671 val enabled =
@@ -671,6 +679,13 @@ object Scanners {
671679 reset()
672680 if atEOL then token = COLONeol
673681
682+ def observeArrowEOL (): Unit =
683+ if indentSyntax && token == ARROW then
684+ peekAhead()
685+ val atEOL = isAfterLineEnd || token == EOF
686+ reset()
687+ if atEOL then token = ARROWeol
688+
674689 def observeIndented (): Unit =
675690 if indentSyntax && isNewLine then
676691 val nextWidth = indentWidth(next.offset)
@@ -679,7 +694,6 @@ object Scanners {
679694 currentRegion = Indented (nextWidth, COLONeol , currentRegion)
680695 offset = next.offset
681696 token = INDENT
682- end observeIndented
683697
684698 /** Insert an <outdent> token if next token closes an indentation region.
685699 * Exception: continue if indentation region belongs to a `match` and next token is `case`.
@@ -1099,7 +1113,7 @@ object Scanners {
10991113 reset()
11001114 next
11011115
1102- class LookaheadScanner (val allowIndent : Boolean = false ) extends Scanner (source, offset, allowIndent = allowIndent) {
1116+ class LookaheadScanner (allowIndent : Boolean = false ) extends Scanner (source, offset, allowIndent = allowIndent) {
11031117 override protected def initialCharBufferSize = 8
11041118 override def languageImportContext = Scanner .this .languageImportContext
11051119 }
@@ -1651,7 +1665,7 @@ object Scanners {
16511665 case class InCase (outer : Region ) extends Region (OUTDENT )
16521666
16531667 /** A class describing an indentation region.
1654- * @param width The principal indendation width
1668+ * @param width The principal indentation width
16551669 * @param prefix The token before the initial <indent> of the region
16561670 */
16571671 case class Indented (width : IndentWidth , prefix : Token , outer : Region | Null ) extends Region (OUTDENT ):
0 commit comments