@@ -636,7 +636,6 @@ object Scanners {
636636 insert(OUTDENT , offset)
637637 else if r.isInstanceOf [InBraces ] && ! closingRegionTokens.contains(token) then
638638 report.warning(" Line is indented too far to the left, or a `}` is missing" , sourcePos())
639-
640639 else if lastWidth < nextWidth
641640 || lastWidth == nextWidth && (lastToken == MATCH || lastToken == CATCH ) && token == CASE then
642641 if canStartIndentTokens.contains(lastToken) then
@@ -656,7 +655,7 @@ object Scanners {
656655 def spaceTabMismatchMsg (lastWidth : IndentWidth , nextWidth : IndentWidth ): Message =
657656 em """ Incompatible combinations of tabs and spaces in indentation prefixes.
658657 |Previous indent : $lastWidth
659- |Latest indent : $nextWidth"""
658+ |Latest indent : $nextWidth"""
660659
661660 def observeColonEOL (inTemplate : Boolean ): Unit =
662661 val enabled =
@@ -670,6 +669,23 @@ object Scanners {
670669 reset()
671670 if atEOL then token = COLONeol
672671
672+ // consume => and insert <indent> if applicable. Used to detect colon arrow: x =>
673+ def observeArrowIndented (): Unit =
674+ if isArrow && indentSyntax then
675+ peekAhead()
676+ val atEOL = isAfterLineEnd
677+ val atEOF = token == EOF
678+ reset()
679+ if atEOF then
680+ token = EOF
681+ else if atEOL then
682+ val nextWidth = indentWidth(next.offset)
683+ val lastWidth = currentRegion.indentWidth
684+ if lastWidth < nextWidth then
685+ currentRegion = Indented (nextWidth, COLONeol , currentRegion)
686+ offset = next.offset
687+ token = INDENT
688+
673689 def observeIndented (): Unit =
674690 if indentSyntax && isNewLine then
675691 val nextWidth = indentWidth(next.offset)
@@ -1098,7 +1114,7 @@ object Scanners {
10981114 reset()
10991115 next
11001116
1101- class LookaheadScanner (val allowIndent : Boolean = false ) extends Scanner (source, offset, allowIndent = allowIndent) {
1117+ class LookaheadScanner (allowIndent : Boolean = false ) extends Scanner (source, offset, allowIndent = allowIndent) {
11021118 override protected def initialCharBufferSize = 8
11031119 override def languageImportContext = Scanner .this .languageImportContext
11041120 }
@@ -1650,7 +1666,7 @@ object Scanners {
16501666 case class InCase (outer : Region ) extends Region (OUTDENT )
16511667
16521668 /** A class describing an indentation region.
1653- * @param width The principal indendation width
1669+ * @param width The principal indentation width
16541670 * @param prefix The token before the initial <indent> of the region
16551671 */
16561672 case class Indented (width : IndentWidth , prefix : Token , outer : Region | Null ) extends Region (OUTDENT ):
0 commit comments