File tree 2 files changed +35
-16
lines changed
src/dotty/tools/dotc/printing
2 files changed +35
-16
lines changed Original file line number Diff line number Diff line change @@ -124,24 +124,30 @@ object SyntaxHighlighting {
124
124
}
125
125
}
126
126
127
- val parser = new Parser (source)
128
- val trees = parser.blockStatSeq()
129
- TreeHighlighter .highlight(trees)
130
-
131
- val highlighted = new StringBuilder ()
132
-
133
- for (idx <- colorAt.indices) {
134
- val prev = if (idx == 0 ) NoColor else colorAt(idx - 1 )
135
- val curr = colorAt(idx)
136
- if (curr != prev)
137
- highlighted.append(curr)
138
- highlighted.append(in(idx))
139
- }
127
+ try
128
+ val parser = new Parser (source)
129
+ val trees = parser.blockStatSeq()
130
+ TreeHighlighter .highlight(trees)
131
+
132
+
133
+ val highlighted = new StringBuilder ()
140
134
141
- if (colorAt.last != NoColor )
142
- highlighted.append(NoColor )
135
+ for (idx <- colorAt.indices) {
136
+ val prev = if (idx == 0 ) NoColor else colorAt(idx - 1 )
137
+ val curr = colorAt(idx)
138
+ if (curr != prev)
139
+ highlighted.append(curr)
140
+ highlighted.append(in(idx))
141
+ }
142
+
143
+ if (colorAt.last != NoColor )
144
+ highlighted.append(NoColor )
143
145
144
- highlighted.toString
146
+ highlighted.toString
147
+ catch
148
+ case e : StackOverflowError =>
149
+ in
145
150
}
146
151
}
152
+
147
153
}
Original file line number Diff line number Diff line change @@ -497,3 +497,16 @@ class ReplVerboseTests extends ReplTest(ReplTest.defaultOptions :+ "-verbose"):
497
497
}
498
498
499
499
end ReplVerboseTests
500
+
501
+ class ReplHighlightTests extends ReplTest (ReplTest .defaultOptions.filterNot(_.startsWith(" -color" )) :+ " -color:always" ):
502
+ @ Test def i18596 : Unit = initially :
503
+ run(""" (1 to 500).foldRight("x") { case (_, n) => s"<x>$n</x>" }""" )
504
+
505
+ @ Test def i16904 : Unit = initially :
506
+ run(""" "works not fine"* 10000""" )
507
+
508
+ run("""
509
+ case class Tree(left: Tree, right: Tree)
510
+ def deepTree(depth: Int): Tree
511
+ deepTree(300)""" )
512
+
You can’t perform that action at this time.
0 commit comments