diff --git a/CHANGELOG.md b/CHANGELOG.md index 386085c..2faaae1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,11 @@ ### Changed - Kotlin version to 1.9.22 +### Fixed +- scientific notation numbers highlight length +- redundant keyword highlights in strings and comments +- ambiguous nested forEach returns + ## [0.7.1] ### Fixed diff --git a/src/commonMain/kotlin/dev/snipme/highlights/internal/locator/NumericLiteralLocator.kt b/src/commonMain/kotlin/dev/snipme/highlights/internal/locator/NumericLiteralLocator.kt index c50f4ab..340a111 100644 --- a/src/commonMain/kotlin/dev/snipme/highlights/internal/locator/NumericLiteralLocator.kt +++ b/src/commonMain/kotlin/dev/snipme/highlights/internal/locator/NumericLiteralLocator.kt @@ -31,7 +31,9 @@ internal object NumericLiteralLocator { } // Find start of literals .forEach { number -> // For given literal find all occurrences - code.indicesOf(number).forEach { startIndex -> + val indices = code.indicesOf(number) + for (startIndex in indices) { + // TODO Correct this and publish if (code.isFullNumber(number, startIndex).not()) return@forEach // Omit in the middle of text, probably variable name (this100) if (code.isNumberFirstIndex(startIndex).not()) return@forEach diff --git a/src/commonMain/kotlin/dev/snipme/highlights/internal/locator/PunctuationLocator.kt b/src/commonMain/kotlin/dev/snipme/highlights/internal/locator/PunctuationLocator.kt index 5e50e12..9d96368 100644 --- a/src/commonMain/kotlin/dev/snipme/highlights/internal/locator/PunctuationLocator.kt +++ b/src/commonMain/kotlin/dev/snipme/highlights/internal/locator/PunctuationLocator.kt @@ -1,9 +1,9 @@ package dev.snipme.highlights.internal.locator -import dev.snipme.highlights.model.PhraseLocation import dev.snipme.highlights.internal.SyntaxTokens.PUNCTUATION_CHARACTERS import dev.snipme.highlights.internal.SyntaxTokens.TOKEN_DELIMITERS import dev.snipme.highlights.internal.indicesOf +import dev.snipme.highlights.model.PhraseLocation internal object PunctuationLocator { fun locate(code: String): List { @@ -14,7 +14,8 @@ internal object PunctuationLocator { .filter { it.isNotBlank() } .filter { it in PUNCTUATION_CHARACTERS } .forEach { - code.indicesOf(it, ).forEach { index -> + val indices = code.indicesOf(it) + for (index in indices) { if (code[index].isWhitespace()) return@forEach locations.add(PhraseLocation(index, index + 1)) }