Skip to content

Commit 03ddf99

Browse files
committed
Remove error listeners from highlighting lexer
fixes #111
1 parent 7a96077 commit 03ddf99

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

ki-shell/src/main/kotlin/org/jetbrains/kotlinx/ki/shell/plugins/KotlinHighlighter.kt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ class KotlinHighlighter(private val styles: SyntaxPlugin.HighlightStyles): BaseH
3535
try {
3636
with(KotlinParserForHighlighting(code)) {
3737
addParseListener(listener)
38-
removeErrorListeners()
3938
script()
4039
}
4140
} catch (e: Throwable) {
@@ -68,10 +67,17 @@ class KotlinHighlighter(private val styles: SyntaxPlugin.HighlightStyles): BaseH
6867
override fun setErrorIndex(p0: Int) {}
6968

7069
private class KotlinParserForHighlighting(code: String) :
71-
KotlinParser(CommonTokenStream(KotlinLexer(CharStreams.fromString(code))))
70+
KotlinParser(
71+
CommonTokenStream(
72+
KotlinLexer(CharStreams.fromString(code)).also {
73+
it.removeErrorListeners()
74+
}
75+
)
76+
)
7277
{
7378
init {
7479
_buildParseTrees = false
80+
removeErrorListeners()
7581
}
7682
}
7783
}

0 commit comments

Comments
 (0)