Skip to content

Commit

Permalink
fix: preset keys abbreviation not working
Browse files Browse the repository at this point in the history
  • Loading branch information
MULE-FEHU-EOLIA-ARTONELICO committed Feb 17, 2025
1 parent 5f9947a commit 2259794
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions app/src/main/java/com/osfans/trime/ime/keyboard/KeyAction.kt
Original file line number Diff line number Diff line change
Expand Up @@ -175,17 +175,13 @@ class KeyAction(

companion object {
private val BRACED_STR = Regex("""\{[^{}]+\}""")
private val KV_PATTERN = Regex("""(\\w+)=(\\w+)""")

private fun decodeMapFromString(str: String): Map<String, String> {
val map = mutableMapOf<String, String>()
val trimmed = str.removeSurrounding("{", "}")
val matches = KV_PATTERN.findAll(trimmed)
for (match in matches) {
val (_, k, v) = match.groupValues
map[k] = v
}
return map
}
private fun decodeMapFromString(str: String): Map<String, String> =
str
.removeSurrounding("{", "}")
.split(", ")
.mapNotNull {
it.split("=").takeIf { it.size == 2 }?.let { (key, value) -> key to value }
}.toMap()
}
}

0 comments on commit 2259794

Please sign in to comment.