From 018bf46ddb47600fd0c875ab0ec463022166a7e6 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 7 Mar 2023 17:01:21 +0530 Subject: [PATCH] kitty @ shell: Integrate completions from history --- tools/cmd/at/shell.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tools/cmd/at/shell.go b/tools/cmd/at/shell.go index 751ebc0d4..e31a89b64 100644 --- a/tools/cmd/at/shell.go +++ b/tools/cmd/at/shell.go @@ -215,7 +215,17 @@ func shell_main(cmd *cli.Command, args []string) (int, error) { } fmt.Println(amsg) } - rl := readline.New(nil, readline.RlInit{Prompt: prompt, Completer: completions, HistoryPath: filepath.Join(utils.CacheDir(), "shell.history.json")}) + var rl *readline.Readline + combined_completer := func(before_cursor, after_cursor string) *cli.Completions { + ans := completions(before_cursor, after_cursor) + history := rl.HistoryCompleter(before_cursor, after_cursor) + for _, group := range history.Groups { + ans.MergeMatchGroup(group) + } + return ans + } + + rl = readline.New(nil, readline.RlInit{Prompt: prompt, Completer: combined_completer, HistoryPath: filepath.Join(utils.CacheDir(), "shell.history.json")}) defer func() { rl.Shutdown() }()