Updated on 2026-08-14
This commit is contained in:
parent
9b6100c09c
commit
282772a0fc
1 changed files with 8 additions and 0 deletions
|
|
@ -4,9 +4,13 @@ import com.tangem.utils.extensions.isNotWhitespace
|
|||
|
||||
/**
|
||||
[REDACTED_AUTHOR]
|
||||
* Class which provides helper functions to determine lead or last part of words for suggestions
|
||||
*/
|
||||
internal class PartWordFinder {
|
||||
|
||||
/**
|
||||
* Searches and return part of a word on the left side of the [cursorPosition] into the [text]
|
||||
*/
|
||||
fun getLeadPartOfWord(text: String, cursorPosition: Int): String? {
|
||||
val charText = text.toCharArray().asList()
|
||||
if (cursorPosition > charText.size || cursorPosition < 0) {
|
||||
|
|
@ -41,6 +45,10 @@ internal class PartWordFinder {
|
|||
return null
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a substring of the [word] which excludes the first word part found on the left of [cursorPosition] in
|
||||
* the [text]
|
||||
*/
|
||||
fun getLastPartOfWord(text: String, word: String, cursorPosition: Int): String {
|
||||
val leadPart = getLeadPartOfWord(text, cursorPosition) ?: return ""
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue