[K/N] Regex matching zero length should split surrogate pairs #KT-57401

Merge-request: KT-MR-11110
Merged-by: Abduqodiri Qurbonzoda <abduqodiri.qurbonzoda@jetbrains.com>
This commit is contained in:
Abduqodiri Qurbonzoda
2023-07-26 14:19:25 +00:00
committed by Space Team
parent 7ecd7b8e61
commit df16fa3306
5 changed files with 12 additions and 40 deletions
@@ -33,12 +33,6 @@ internal class EmptySet(override var next: AbstractSet) : LeafSet() {
override fun find(startIndex: Int, testString: CharSequence, matchResult: MatchResultImpl): Int {
for (index in startIndex..testString.length) {
if (index < testString.length) {
if (testString[index].isLowSurrogate() &&
index > 0 && testString[index - 1].isHighSurrogate()) {
continue
}
}
if (next.matches(index, testString, matchResult) >= 0) {
return index
}
@@ -48,12 +42,6 @@ internal class EmptySet(override var next: AbstractSet) : LeafSet() {
override fun findBack(leftLimit: Int, rightLimit: Int, testString: CharSequence, matchResult: MatchResultImpl): Int {
for (index in rightLimit downTo leftLimit) {
if (index < testString.length) {
if (testString[index].isLowSurrogate() &&
index > 0 && testString[index - 1].isHighSurrogate()) {
continue
}
}
if (next.matches(index, testString, matchResult) >= 0) {
return index
}