0
0
Fork 0
mirror of https://github.com/schollz/croc.git synced 2025-10-11 13:21:00 +02:00

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

View file

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