From 2f6f75b3a46094e8baca2d4dfdcb81968e004e98 Mon Sep 17 00:00:00 2001 From: Lo Date: Mon, 13 Jan 2025 17:46:40 +0100 Subject: [PATCH] Mindre fixar med auto slut --- input_parser/auto_complete.go | 24 +++++++++--------------- input_parser/auto_complete_history.go | 2 +- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/input_parser/auto_complete.go b/input_parser/auto_complete.go index 20d28f1..bcb55e9 100644 --- a/input_parser/auto_complete.go +++ b/input_parser/auto_complete.go @@ -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 diff --git a/input_parser/auto_complete_history.go b/input_parser/auto_complete_history.go index 11368a2..e82bfb7 100644 --- a/input_parser/auto_complete_history.go +++ b/input_parser/auto_complete_history.go @@ -10,7 +10,7 @@ func AutoCompleteHistory(input string, env environment.Env) string { return "" } - tabIndex = 0 + // tabIndex = 0 // currentCommands := []string{ // "cat",