Small optimization + consistent variable names style

This commit is contained in:
BayLee4 2023-01-13 16:29:11 +01:00
parent 0024beaedc
commit adadaba75e
No known key found for this signature in database
GPG Key ID: F38A8009E8321253
1 changed files with 6 additions and 5 deletions

View File

@ -359,18 +359,19 @@ type TabComplete struct{}
func (t TabComplete) Do(line []rune, pos int) ([][]rune, int) {
var words = strings.SplitAfter(string(line), "-")
var last_partial_word = words[len(words)-1]
if len(last_partial_word) == 0 {
var lastPartialWord = words[len(words)-1]
var nbCharacter = len(lastPartialWord)
if nbCharacter == 0 {
// No completion
return [][]rune{[]rune("")}, 0
}
var strArray [][]rune
for _, s := range mnemonicode.WordList {
if strings.HasPrefix(s, last_partial_word) {
strArray = append(strArray, []rune(s[len(last_partial_word):]))
if strings.HasPrefix(s, lastPartialWord) {
strArray = append(strArray, []rune(s[nbCharacter:]))
}
}
return strArray, len(last_partial_word)
return strArray, nbCharacter
}
func receive(c *cli.Context) (err error) {