Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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<PhraseLocation> {
Expand All @@ -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))
}
Expand Down