@@ -636,7 +636,6 @@ object Scanners {
636
636
insert(OUTDENT , offset)
637
637
else if r.isInstanceOf [InBraces ] && ! closingRegionTokens.contains(token) then
638
638
report.warning(" Line is indented too far to the left, or a `}` is missing" , sourcePos())
639
-
640
639
else if lastWidth < nextWidth
641
640
|| lastWidth == nextWidth && (lastToken == MATCH || lastToken == CATCH ) && token == CASE then
642
641
if canStartIndentTokens.contains(lastToken) then
@@ -656,7 +655,7 @@ object Scanners {
656
655
def spaceTabMismatchMsg (lastWidth : IndentWidth , nextWidth : IndentWidth ): Message =
657
656
em """ Incompatible combinations of tabs and spaces in indentation prefixes.
658
657
|Previous indent : $lastWidth
659
- |Latest indent : $nextWidth"""
658
+ |Latest indent : $nextWidth"""
660
659
661
660
def observeColonEOL (inTemplate : Boolean ): Unit =
662
661
val enabled =
@@ -670,6 +669,23 @@ object Scanners {
670
669
reset()
671
670
if atEOL then token = COLONeol
672
671
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
+
673
689
def observeIndented (): Unit =
674
690
if indentSyntax && isNewLine then
675
691
val nextWidth = indentWidth(next.offset)
@@ -1098,7 +1114,7 @@ object Scanners {
1098
1114
reset()
1099
1115
next
1100
1116
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) {
1102
1118
override protected def initialCharBufferSize = 8
1103
1119
override def languageImportContext = Scanner .this .languageImportContext
1104
1120
}
@@ -1650,7 +1666,7 @@ object Scanners {
1650
1666
case class InCase (outer : Region ) extends Region (OUTDENT )
1651
1667
1652
1668
/** A class describing an indentation region.
1653
- * @param width The principal indendation width
1669
+ * @param width The principal indentation width
1654
1670
* @param prefix The token before the initial <indent> of the region
1655
1671
*/
1656
1672
case class Indented (width : IndentWidth , prefix : Token , outer : Region | Null ) extends Region (OUTDENT ):
0 commit comments