Merge pull request #4566 from vector-im/feature/adm/typing-emoji-leftovers
Emoji insertion leftover characters
This commit is contained in:
commit
173ccc6bd4
1
changelog.d/3449.bugfix
Normal file
1
changelog.d/3449.bugfix
Normal file
@ -0,0 +1 @@
|
|||||||
|
Fixes left over text when inserting emojis via the ':' menu and replaces the last typed ':' rather than the one at the end of the message
|
@ -181,8 +181,8 @@ class AutoCompleter @AssistedInject constructor(
|
|||||||
.with(backgroundDrawable)
|
.with(backgroundDrawable)
|
||||||
.with(object : AutocompleteCallback<String> {
|
.with(object : AutocompleteCallback<String> {
|
||||||
override fun onPopupItemClicked(editable: Editable, item: String): Boolean {
|
override fun onPopupItemClicked(editable: Editable, item: String): Boolean {
|
||||||
// Detect last ":" and remove it
|
// Infer that the last ":" before the current cursor position is the original popup trigger
|
||||||
var startIndex = editable.lastIndexOf(":")
|
var startIndex = editable.subSequence(0, editText.selectionStart).lastIndexOf(":")
|
||||||
if (startIndex == -1) {
|
if (startIndex == -1) {
|
||||||
startIndex = 0
|
startIndex = 0
|
||||||
}
|
}
|
||||||
@ -194,7 +194,8 @@ class AutoCompleter @AssistedInject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Replace the word by its completion
|
// Replace the word by its completion
|
||||||
editable.replace(startIndex, endIndex, item)
|
editable.delete(startIndex, endIndex)
|
||||||
|
editable.insert(startIndex, item)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user