Mindre fixar med auto slut
This commit is contained in:
parent
0216b72d65
commit
2f6f75b3a4
@ -6,33 +6,24 @@ var tabIndex int
|
||||
|
||||
func AutoComplete(input string) string {
|
||||
|
||||
// print(" commandsTab ")
|
||||
// print(len(commandsTab))
|
||||
// print(" prevInput ")
|
||||
// print(prevInput)
|
||||
// print(" tabIndex ")
|
||||
// print(tabIndex)
|
||||
|
||||
inputLength := len(input)
|
||||
|
||||
// print(" inputLength ")
|
||||
// print(inputLength)
|
||||
|
||||
if inputLength == 0 {
|
||||
return input
|
||||
}
|
||||
|
||||
if tabIndex+2 > len(commandsTab) {
|
||||
tabIndex = -1
|
||||
}
|
||||
|
||||
if prevInput == input {
|
||||
|
||||
tabIndex = tabIndex + 1
|
||||
|
||||
if len(commandsTab) == 0 && tabIndex > -1 {
|
||||
if len(commandsTab) == 0 && tabIndex > 0 {
|
||||
return input
|
||||
}
|
||||
|
||||
if tabIndex > len(commandsTab)-1 {
|
||||
tabIndex = 0
|
||||
}
|
||||
|
||||
prevInput = commandsTab[tabIndex]
|
||||
return commandsTab[tabIndex]
|
||||
}
|
||||
@ -45,6 +36,8 @@ func AutoComplete(input string) string {
|
||||
"cd",
|
||||
"cp",
|
||||
"echo",
|
||||
"exit",
|
||||
"fritiofcommand",
|
||||
"head",
|
||||
"help",
|
||||
"ls",
|
||||
@ -54,6 +47,7 @@ func AutoComplete(input string) string {
|
||||
"rm",
|
||||
"tail",
|
||||
"touch",
|
||||
"whereareyou",
|
||||
}
|
||||
|
||||
var commandsWorking []string
|
||||
|
||||
@ -10,7 +10,7 @@ func AutoCompleteHistory(input string, env environment.Env) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
tabIndex = 0
|
||||
// tabIndex = 0
|
||||
|
||||
// currentCommands := []string{
|
||||
// "cat",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user