Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/3449.bugfix
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ class AutoCompleter @AssistedInject constructor(
.with(backgroundDrawable)
.with(object : AutocompleteCallback<String> {
override fun onPopupItemClicked(editable: Editable, item: String): Boolean {
// Detect last ":" and remove it
var startIndex = editable.lastIndexOf(":")
// Infer that the last ":" before the current cursor position is the original popup trigger
var startIndex = editable.subSequence(0, editText.selectionStart).lastIndexOf(":")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe update the comment above?

Copy link
Contributor Author

@ouchadam ouchadam Nov 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (startIndex == -1) {
startIndex = 0
}
Expand All @@ -194,7 +194,8 @@ class AutoCompleter @AssistedInject constructor(
}

// Replace the word by its completion
editable.replace(startIndex, endIndex, item)
editable.delete(startIndex, endIndex)
editable.insert(startIndex, item)
return true
}

Expand Down