Skip to content

Commit

Permalink
detect the error, but how to replace?
Browse files Browse the repository at this point in the history
Signed-off-by: rapterjet2004 <[email protected]>
  • Loading branch information
rapterjet2004 committed Feb 11, 2025
1 parent 4feac1c commit 2c3448f
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions app/src/main/java/com/nextcloud/talk/chat/MessageInputFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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")

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)
start < editable.getSpanEnd(mentionSpan) &&
what != mentionSpan.label
) {
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)
editable.removeSpan(mentionSpan)
if (error) {
Log.d("Julius", "Error: Fix mention")
}
}
}
Expand Down

0 comments on commit 2c3448f

Please sign in to comment.