From c558c257d14395106719c8055ab0b70381dcdafb Mon Sep 17 00:00:00 2001 From: Mitja Leino Date: Fri, 7 Jun 2024 06:25:06 +0300 Subject: [PATCH] Use the actual length --- .../com/mituuz/fuzzier/entities/FuzzyMatchContainer.kt | 7 +++---- .../com/mituuz/fuzzier/entities/FuzzyMatchContainerTest.kt | 1 - 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/com/mituuz/fuzzier/entities/FuzzyMatchContainer.kt b/src/main/kotlin/com/mituuz/fuzzier/entities/FuzzyMatchContainer.kt index 6a2c425..b684c07 100644 --- a/src/main/kotlin/com/mituuz/fuzzier/entities/FuzzyMatchContainer.kt +++ b/src/main/kotlin/com/mituuz/fuzzier/entities/FuzzyMatchContainer.kt @@ -29,8 +29,6 @@ import com.mituuz.fuzzier.settings.FuzzierSettingsService class FuzzyMatchContainer(val score: FuzzyScore, var filePath: String, var filename: String, private var module: String = "") { private val sm: String = "" private val em: String = "" -// private val sm: String = "" -// private val em: String = "" private var initialPath: String? = null companion object { fun createOrderedContainer(order: Int, filePath: String, initialPath:String, filename: String): FuzzyMatchContainer { @@ -57,8 +55,9 @@ class FuzzyMatchContainer(val score: FuzzyScore, var filePath: String, var filen for (i in score.highlightCharacters) { if (i < source.length) { stringBuilder.insert(i + offset, sm) - stringBuilder.insert(i + offset + 41, em) // 7 - offset += 6 + 41 // 7 + offset += sm.length + stringBuilder.insert(i + offset + 1, em) + offset += em.length } } return stringBuilder.toString() diff --git a/src/test/kotlin/com/mituuz/fuzzier/entities/FuzzyMatchContainerTest.kt b/src/test/kotlin/com/mituuz/fuzzier/entities/FuzzyMatchContainerTest.kt index a16d98c..60c6273 100644 --- a/src/test/kotlin/com/mituuz/fuzzier/entities/FuzzyMatchContainerTest.kt +++ b/src/test/kotlin/com/mituuz/fuzzier/entities/FuzzyMatchContainerTest.kt @@ -11,7 +11,6 @@ class FuzzyMatchContainerTest { s.highlightCharacters.add(0) s.highlightCharacters.add(4) val f = FuzzyMatchContainer(s, "", "Hello") - // assertEquals("Hello", f.highlight(f.filename)) assertEquals("Hello", f.highlight(f.filename)) } } \ No newline at end of file