Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package helium314.keyboard.latin.utils

import android.content.ClipboardManager
import android.content.Context
import android.content.res.ColorStateList
import org.json.JSONObject
import java.text.SimpleDateFormat
import java.util.Date
Expand All @@ -32,8 +31,6 @@ object TextExpanderUtils {
return context.prefs().getBoolean(PREF_BACKSPACE_REVERTS, false)
}



data class ShortcutEntry(
val template: String,
val prefix: String = ""
Expand Down Expand Up @@ -245,8 +242,9 @@ object TextExpanderUtils {
val regex = Regex(patternStr, RegexOption.IGNORE_CASE)
val expectedSuffix = prefix + word
if (textBeforeCursor.endsWith(expectedSuffix, ignoreCase = true)) {
if (regex.matches(expectedSuffix)) {
val replaced = regex.replace(expectedSuffix, entry.template)
val matchInput = if (expectedSuffix.startsWith(prefix)) expectedSuffix.substring(prefix.length) else expectedSuffix
if (regex.matches(matchInput)) {
val replaced = regex.replace(matchInput, entry.template)
return ExpandedResult(expand(replaced, context), prefix.length, expectedSuffix)
}
}
Expand Down Expand Up @@ -276,3 +274,4 @@ object TextExpanderUtils {
return null
}
}

Loading