From 75fa0989a9f64b95c3b71fe3ada33105cbce08cc Mon Sep 17 00:00:00 2001 From: Igor Furgala Date: Tue, 9 Sep 2025 10:33:49 +0200 Subject: [PATCH] fix: improve handling mentions on android --- .../com/swmansion/enriched/styles/ParametrizedStyles.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/android/src/main/java/com/swmansion/enriched/styles/ParametrizedStyles.kt b/android/src/main/java/com/swmansion/enriched/styles/ParametrizedStyles.kt index acddfac7b..4cf6d7139 100644 --- a/android/src/main/java/com/swmansion/enriched/styles/ParametrizedStyles.kt +++ b/android/src/main/java/com/swmansion/enriched/styles/ParametrizedStyles.kt @@ -148,7 +148,7 @@ class ParametrizedStyles(private val view: EnrichedTextInputView) { mentionStart = start } - mentionHandler.onMention(indicator, word.replaceFirst(indicator, "")) + mentionHandler.onMention(indicator, text) } else { mentionHandler.endMention() } @@ -208,6 +208,11 @@ class ParametrizedStyles(private val view: EnrichedTextInputView) { val (safeStart, safeEnd) = spannable.getSafeSpanBoundaries(start, spanEnd) spannable.setSpan(span, safeStart, safeEnd, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE) + val hasSpaceAtTheEnd = spannable.length > safeEnd && spannable[safeEnd] == ' ' + if (!hasSpaceAtTheEnd) { + spannable.insert(safeEnd, " ") + } + view.selection.validateStyles() }