File tree Expand file tree Collapse file tree
android/src/main/java/com/swmansion/enriched/textinput/styles Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -280,12 +280,16 @@ class ParametrizedStyles(
280280
281281 // No previous word -> no mention to be detected
282282 if (previousWord == null ) {
283+ mentionStart = null
284+ mentionEnd = null
283285 mentionHandler.endMention()
284286 return
285287 }
286288
287289 // Previous word is not a mention -> end mention
288290 if (! mentionRegex.matches(previousWord.text)) {
291+ mentionStart = null
292+ mentionEnd = null
289293 mentionHandler.endMention()
290294 return
291295 }
@@ -314,6 +318,8 @@ class ParametrizedStyles(
314318 val spanEnd = spannable.getSpanEnd(span)
315319 val currentSpanText = spannable.subSequence(spanStart, spanEnd).toString()
316320 if (currentSpanText == span.getText()) {
321+ mentionStart = null
322+ mentionEnd = null
317323 mentionHandler.endMention()
318324 return
319325 }
@@ -405,9 +411,8 @@ class ParametrizedStyles(
405411 val hasSpaceAtTheEnd = spannable.length > safeEnd && spannable[safeEnd] == ' '
406412 if (! hasSpaceAtTheEnd) {
407413 spannable.insert(safeEnd, " " )
408- } else {
409- Selection .setSelection(spannable, safeEnd + 1 )
410414 }
415+ Selection .setSelection(spannable, (safeEnd + 1 ).coerceAtMost(spannable.length))
411416 }
412417
413418 view.mentionHandler?.reset()
You can’t perform that action at this time.
0 commit comments