Implement smarter history navigation (#2161)

* Remove unnecessary space in history file

* Refactor history navigation

* Implement smarter history navigation

* Skip duplicate commands in history navigation

* Return to Normal mode if it started from there

* Reset history state when changing prompt

* Update documentation
This commit is contained in:
Joe Lim authored and GitHub committed 2025-09-19 19:44:43 +10:00
1 parent 5e15655539
commit 89ff7b0203
6 files changed
+96 -86

No files matched your search

+2 -2
View File
@@ -1267,7 +1267,7 @@ func listJumps(jumps []string, ind int) string {
return b.String()
}
func listHistory(history []cmdItem) string {
func listHistory(history []string) string {
t := new(tabwriter.Writer)
b := new(bytes.Buffer)
@@ -1276,7 +1276,7 @@ func listHistory(history []cmdItem) string {
t.Init(b, 0, gOpts.tabstop, 2, '\t', 0)
fmt.Fprintln(t, "number\tcommand")
for i, cmd := range history {
fmt.Fprintf(t, "%*d\t%s%s\n", maxlength, i+1, cmd.prefix, cmd.value)
fmt.Fprintf(t, "%*d\t%s\n", maxlength, i+1, cmd)
}
t.Flush()