aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTulir Asokan <tulir@maunium.net>2019-06-16 19:54:54 +0300
committerTulir Asokan <tulir@maunium.net>2019-06-16 19:54:54 +0300
commit691708a76ef6bb0eee8869582647a19946d787c1 (patch)
treeb0ab2f6461874ee4277936511e9d5b2fa521ad6b
parent7f917f027127b46f219eaa8a6c696c4e078f6d04 (diff)
Improve emoji autocompletion when the same emoji has many names
-rw-r--r--ui/room-view.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/ui/room-view.go b/ui/room-view.go
index 00aa09a..a257f63 100644
--- a/ui/room-view.go
+++ b/ui/room-view.go
@@ -333,13 +333,23 @@ func (view *RoomView) autocompleteEmoji(word string) (completions []string) {
if len(word) == 0 || word[0] != ':' {
return
}
+ var valueCompletion1 string
+ var manyValues bool
for name, value := range emoji.CodeMap() {
if name == word {
return []string{value}
} else if strings.HasPrefix(name, word) {
completions = append(completions, name)
+ if valueCompletion1 == "" {
+ valueCompletion1 = value
+ } else if valueCompletion1 != value {
+ manyValues = true
+ }
}
}
+ if !manyValues && len(completions) > 0 {
+ return []string{emoji.CodeMap()[completions[0]]}
+ }
return
}