Skip to content

Commit 5ee87bc

Browse files
authored
fix: improve handling mentions on android (#150)
## Changes - this ensures that we add a space (if needed) after setting up mention
1 parent d26963f commit 5ee87bc

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

android/src/main/java/com/swmansion/enriched/styles/ParametrizedStyles.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ class ParametrizedStyles(private val view: EnrichedTextInputView) {
148148
mentionStart = start
149149
}
150150

151-
mentionHandler.onMention(indicator, word.replaceFirst(indicator, ""))
151+
mentionHandler.onMention(indicator, text)
152152
} else {
153153
mentionHandler.endMention()
154154
}
@@ -208,6 +208,11 @@ class ParametrizedStyles(private val view: EnrichedTextInputView) {
208208
val (safeStart, safeEnd) = spannable.getSafeSpanBoundaries(start, spanEnd)
209209
spannable.setSpan(span, safeStart, safeEnd, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
210210

211+
val hasSpaceAtTheEnd = spannable.length > safeEnd && spannable[safeEnd] == ' '
212+
if (!hasSpaceAtTheEnd) {
213+
spannable.insert(safeEnd, " ")
214+
}
215+
211216
view.selection.validateStyles()
212217
}
213218

0 commit comments

Comments
 (0)