@@ -641,7 +641,7 @@ object Parsers {
641
641
def inBracesOrIndented [T ](body : => T , rewriteWithColon : Boolean = false ): T =
642
642
if in.token == INDENT then
643
643
val rewriteToBraces = in.rewriteNoIndent
644
- && ! testCharsSafe (in.lastOffset - 3 , " =>" ) // braces are optional after `=>` so none should be inserted
644
+ && ! testChars (in.lastOffset - 3 , " =>" ) // braces are optional after `=>` so none should be inserted
645
645
if rewriteToBraces then indentedToBraces(body)
646
646
else enclosed(INDENT , body)
647
647
else
@@ -732,21 +732,19 @@ object Parsers {
732
732
733
733
def testChar (idx : Int , p : Char => Boolean ): Boolean = {
734
734
val txt = source.content
735
- idx < txt.length && p(txt(idx))
735
+ idx >= 0 && idx < txt.length && p(txt(idx))
736
736
}
737
737
738
738
def testChar (idx : Int , c : Char ): Boolean = {
739
739
val txt = source.content
740
- idx < txt.length && txt(idx) == c
740
+ idx >= 0 && idx < txt.length && txt(idx) == c
741
741
}
742
742
743
743
def testChars (from : Int , str : String ): Boolean =
744
- str.isEmpty ||
744
+ str.isEmpty
745
+ ||
745
746
testChar(from, str.head) && testChars(from + 1 , str.tail)
746
747
747
- def testCharsSafe (from : Int , str : String ): Boolean =
748
- from >= 0 && testChars(from, str)
749
-
750
748
def skipBlanks (idx : Int , step : Int = 1 ): Int =
751
749
if (testChar(idx, c => c == ' ' || c == '\t ' || c == Chars .CR )) skipBlanks(idx + step, step)
752
750
else idx
@@ -863,7 +861,7 @@ object Parsers {
863
861
case _ => false
864
862
}
865
863
var canRewrite = allBraces(in.currentRegion) && // test (1)
866
- ! testCharsSafe (in.lastOffset - 3 , " =>" ) // test(6)
864
+ ! testChars (in.lastOffset - 3 , " =>" ) // test(6)
867
865
868
866
def isStartOfSymbolicFunction : Boolean =
869
867
opStack.headOption.exists { x =>
0 commit comments