From 91cd20adc3a3b3b1377551c886fa500ffda4ce9a Mon Sep 17 00:00:00 2001 From: tkadziolka Date: Sun, 25 Feb 2024 22:06:42 +0100 Subject: [PATCH 1/2] Updated changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 386085c..b6c5e77 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,10 @@ ### Changed - Kotlin version to 1.9.22 +### Fixed +- scientific notation numbers highlight length +- redundant keyword highlights in strings and comments + ## [0.7.1] ### Fixed From 63f173bb745ee8e44f3e30244ca24ea0a1d7d3bb Mon Sep 17 00:00:00 2001 From: tkadziolka Date: Mon, 26 Feb 2024 10:35:17 +0100 Subject: [PATCH 2/2] Prepared code for 0.8.0 release --- CHANGELOG.md | 1 + .../highlights/internal/locator/NumericLiteralLocator.kt | 4 +++- .../snipme/highlights/internal/locator/PunctuationLocator.kt | 5 +++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b6c5e77..2faaae1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ ### Fixed - scientific notation numbers highlight length - redundant keyword highlights in strings and comments +- ambiguous nested forEach returns ## [0.7.1] 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)) }