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 {
|
func AutoComplete(input string) string {
|
||||||
|
|
||||||
// print(" commandsTab ")
|
|
||||||
// print(len(commandsTab))
|
|
||||||
// print(" prevInput ")
|
|
||||||
// print(prevInput)
|
|
||||||
// print(" tabIndex ")
|
|
||||||
// print(tabIndex)
|
|
||||||
|
|
||||||
inputLength := len(input)
|
inputLength := len(input)
|
||||||
|
|
||||||
// print(" inputLength ")
|
|
||||||
// print(inputLength)
|
|
||||||
|
|
||||||
if inputLength == 0 {
|
if inputLength == 0 {
|
||||||
return input
|
return input
|
||||||
}
|
}
|
||||||
|
|
||||||
if tabIndex+2 > len(commandsTab) {
|
|
||||||
tabIndex = -1
|
|
||||||
}
|
|
||||||
|
|
||||||
if prevInput == input {
|
if prevInput == input {
|
||||||
|
|
||||||
tabIndex = tabIndex + 1
|
tabIndex = tabIndex + 1
|
||||||
|
|
||||||
if len(commandsTab) == 0 && tabIndex > -1 {
|
if len(commandsTab) == 0 && tabIndex > 0 {
|
||||||
return input
|
return input
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if tabIndex > len(commandsTab)-1 {
|
||||||
|
tabIndex = 0
|
||||||
|
}
|
||||||
|
|
||||||
prevInput = commandsTab[tabIndex]
|
prevInput = commandsTab[tabIndex]
|
||||||
return commandsTab[tabIndex]
|
return commandsTab[tabIndex]
|
||||||
}
|
}
|
||||||
@ -45,6 +36,8 @@ func AutoComplete(input string) string {
|
|||||||
"cd",
|
"cd",
|
||||||
"cp",
|
"cp",
|
||||||
"echo",
|
"echo",
|
||||||
|
"exit",
|
||||||
|
"fritiofcommand",
|
||||||
"head",
|
"head",
|
||||||
"help",
|
"help",
|
||||||
"ls",
|
"ls",
|
||||||
@ -54,6 +47,7 @@ func AutoComplete(input string) string {
|
|||||||
"rm",
|
"rm",
|
||||||
"tail",
|
"tail",
|
||||||
"touch",
|
"touch",
|
||||||
|
"whereareyou",
|
||||||
}
|
}
|
||||||
|
|
||||||
var commandsWorking []string
|
var commandsWorking []string
|
||||||
|
|||||||
@ -10,7 +10,7 @@ func AutoCompleteHistory(input string, env environment.Env) string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
tabIndex = 0
|
// tabIndex = 0
|
||||||
|
|
||||||
// currentCommands := []string{
|
// currentCommands := []string{
|
||||||
// "cat",
|
// "cat",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user