detect the error, but how to replace?

Signed-off-by: rapterjet2004 <juliuslinus1@gmail.com>
This commit is contained in:
rapterjet2004 2025-02-11 15:24:27 -06:00
parent 4feac1cb50
commit 2c3448f328
No known key found for this signature in database
GPG Key ID: A6A69CFF84968EA1

View File

@ -366,23 +366,20 @@ class MessageInputFragment : Fragment() {
var mentionSpan: Spans.MentionChipSpan
for (i in mentionSpans.indices) {
mentionSpan = mentionSpans[i]
val start = editable.getSpanStart(mentionSpan)
val end = editable.getSpanEnd(mentionSpan)
Log.d("Julius", "S:$start E:$end")
if (start >= editable.getSpanStart(mentionSpan) &&
start < editable.getSpanEnd(mentionSpan)
) {
val what = editable.subSequence(
editable.getSpanStart(mentionSpan),
editable.getSpanEnd(mentionSpan)
).toString()
if (what.trim { it <= ' ' } != mentionSpan.label
) {
Log.d("Julius", "What: $what")
Log.d("Julius", "MentionSpan removed: $mentionSpan")
// FIXME error here- I knew it I was right, but why?
// editable.removeSpan(mentionSpan)
val what = editable.subSequence(
editable.getSpanStart(mentionSpan),
editable.getSpanEnd(mentionSpan)
).toString().trim { it <= ' ' }
val error = what.length > mentionSpan.label.length
if (start >= editable.getSpanStart(mentionSpan) &&
start < editable.getSpanEnd(mentionSpan) &&
what != mentionSpan.label
) {
editable.removeSpan(mentionSpan)
if (error) {
Log.d("Julius", "Error: Fix mention")
}
}
}