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
1 changed files with 6 additions and 4 deletions

View File

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