@@ -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
@@ -638,9 +642,13 @@ object Scanners {
638642 insert(OUTDENT , offset)
639643 else if r.isInstanceOf [InBraces ] && ! closingRegionTokens.contains(token) then
640644 report.warning(" Line is indented too far to the left, or a `}` is missing" , sourcePos())
641-
642645 else if lastWidth < nextWidth
643- || lastWidth == nextWidth && (lastToken == MATCH || lastToken == CATCH ) && token == CASE then
646+ || lastWidth == nextWidth
647+ && lastToken.match
648+ case MATCH | CATCH => token == CASE
649+ case ARROWeol => true
650+ case _ => false
651+ then
644652 if canStartIndentTokens.contains(lastToken) then
645653 currentRegion = Indented (nextWidth, lastToken, currentRegion)
646654 insert(INDENT , offset)
@@ -658,7 +666,7 @@ object Scanners {
658666 def spaceTabMismatchMsg (lastWidth : IndentWidth , nextWidth : IndentWidth ): Message =
659667 em """ Incompatible combinations of tabs and spaces in indentation prefixes.
660668 |Previous indent : $lastWidth
661- |Latest indent : $nextWidth"""
669+ |Latest indent : $nextWidth"""
662670
663671 def observeColonEOL (inTemplate : Boolean ): Unit =
664672 val enabled =
@@ -672,6 +680,13 @@ object Scanners {
672680 reset()
673681 if atEOL then token = COLONeol
674682
683+ def observeArrowEOL (): Unit =
684+ if indentSyntax && token == ARROW then
685+ peekAhead()
686+ val atEOL = isAfterLineEnd || token == EOF
687+ reset()
688+ if atEOL then token = ARROWeol
689+
675690 def observeIndented (): Unit =
676691 if indentSyntax && isNewLine then
677692 val nextWidth = indentWidth(next.offset)
@@ -680,7 +695,6 @@ object Scanners {
680695 currentRegion = Indented (nextWidth, COLONeol , currentRegion)
681696 offset = next.offset
682697 token = INDENT
683- end observeIndented
684698
685699 /** Insert an <outdent> token if next token closes an indentation region.
686700 * Exception: continue if indentation region belongs to a `match` and next token is `case`.
@@ -1100,7 +1114,7 @@ object Scanners {
11001114 reset()
11011115 next
11021116
1103- class LookaheadScanner (val allowIndent : Boolean = false ) extends Scanner (source, offset, allowIndent = allowIndent) {
1117+ class LookaheadScanner (allowIndent : Boolean = false ) extends Scanner (source, offset, allowIndent = allowIndent) {
11041118 override protected def initialCharBufferSize = 8
11051119 override def languageImportContext = Scanner .this .languageImportContext
11061120 }
@@ -1652,7 +1666,7 @@ object Scanners {
16521666 case class InCase (outer : Region ) extends Region (OUTDENT )
16531667
16541668 /** A class describing an indentation region.
1655- * @param width The principal indendation width
1669+ * @param width The principal indentation width
16561670 * @param prefix The token before the initial <indent> of the region
16571671 */
16581672 case class Indented (width : IndentWidth , prefix : Token , outer : Region | Null ) extends Region (OUTDENT ):
0 commit comments