always use getText().insert for adding pills

This commit is contained in:
David Langley 2023-06-09 14:58:17 +01:00
parent 3157a35b74
commit f3db4a857a
1 changed files with 7 additions and 8 deletions

View File

@ -808,15 +808,14 @@ class MessageComposerFragment : VectorBaseFragment<FragmentComposerBinding>(), A
) )
append(if (startToCompose) ": " else " ") append(if (startToCompose) ": " else " ")
} }
if (startToCompose) { if (startToCompose && displayName.startsWith("/")) {
if (displayName.startsWith("/")) {
// Ensure displayName will not be interpreted as a Slash command // Ensure displayName will not be interpreted as a Slash command
composer.editText.append("\\") composer.editText.append("\\")
} }
composer.editText.append(pill) // Always use EditText.getText().insert for adding pills as TextView.append doesn't appear
} else { // to upgrade to BufferType.Spannable as hinted at in the docs:
composer.editText.text?.insert(composer.editText.selectionStart, pill) // https://developer.android.com/reference/android/widget/TextView#append(java.lang.CharSequence)
} composer.editText.text.insert(composer.editText.selectionStart, pill)
} }
focusComposerAndShowKeyboard() focusComposerAndShowKeyboard()
} }