diff --git a/tools/lexer/idea-flex-kotlin.skeleton b/tools/lexer/idea-flex-kotlin.skeleton index e241f679f5ba..49882c195f9b 100644 --- a/tools/lexer/idea-flex-kotlin.skeleton +++ b/tools/lexer/idea-flex-kotlin.skeleton @@ -201,6 +201,17 @@ companion object { private fun charCount(codePoint: Int): Int = if (codePoint < 0x10000) 1 else 2 + private fun Char.Companion.codePointBefore(seq: CharSequence, index: Int): Int { + var i = index - 1 + val c2 = seq[i]; + if (c2.isLowSurrogate() && index > 0) { + val c1 = seq[i - 1]; + if (c1.isHighSurrogate()) { + return Char.toCodePoint(c1, c2); + } + } + return c2.code + } /** * Reports an error that occurred while scanning.