Skip to content

Commit

Permalink
Use the actual length
Browse files Browse the repository at this point in the history
  • Loading branch information
MituuZ committed Jun 7, 2024
1 parent f4fbd02 commit c558c25
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "<font style='background-color: yellow;'>"
private val em: String = "</font>"
// private val sm: String = "<mark>"
// private val em: String = "</mark>"
private var initialPath: String? = null
companion object {
fun createOrderedContainer(order: Int, filePath: String, initialPath:String, filename: String): FuzzyMatchContainer {
Expand All @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ class FuzzyMatchContainerTest {
s.highlightCharacters.add(0)
s.highlightCharacters.add(4)
val f = FuzzyMatchContainer(s, "", "Hello")
// assertEquals("<mark>H</mark>ell<mark>o</mark>", f.highlight(f.filename))
assertEquals("<font style='background-color: yellow;'>H</font>ell<font style='background-color: yellow;'>o</font>", f.highlight(f.filename))
}
}

0 comments on commit c558c25

Please sign in to comment.