Fix tree generation breaking subtrees

This commit is contained in:
Hamcha 2018-11-15 18:37:49 +01:00
parent b32820410d
commit 33cbf9f25f
Signed by: hamcha
GPG key ID: A40413D21021EAEE

View file

@ -49,7 +49,8 @@ func (em emojiTable) Find(str string) *emoji {
}
// Check if there are more bytes to check
if len(str) > i && e.Sub != nil {
newemj := e.Sub.Find(str[i:])
rlen := utf8.RuneLen(r)
newemj := e.Sub.Find(str[i+rlen:])
if newemj != nil {
return newemj
}
@ -130,13 +131,14 @@ func scanEmojiDirectory(emojipath string) (tab emojiTable, err error) {
newemo.IsEmoji = true
newemo.Path = path
} else {
// Add sub-entry
newemo.Sub = make(emojiTable)
// Add sub-entry if not existant
if newemo.Sub == nil {
newemo.Sub = make(emojiTable)
}
}
(*curtab)[cprune] = newemo
curtab = &newemo.Sub
}
fmt.Println(codepointstr)
return nil
})
return tab, err