From 9c11ab21c73cecf80a243d8dfb55b7793da7bb96 Mon Sep 17 00:00:00 2001 From: Moritz Poldrack Date: Wed, 14 Sep 2022 18:34:48 +0200 Subject: history: don't store duplicate entries Signed-off-by: Moritz Poldrack Acked-by: Tim Culverhouse Acked-by: Robin Jarry --- commands/history.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'commands/history.go') diff --git a/commands/history.go b/commands/history.go index 77bb1553..1c0a1ec8 100644 --- a/commands/history.go +++ b/commands/history.go @@ -23,7 +23,9 @@ func (h *cmdHistory) Add(cmd string) { h.cmdList = h.cmdList[1:] } - h.cmdList = append(h.cmdList, cmd) + if len(h.cmdList) == 0 || h.cmdList[len(h.cmdList)-1] != cmd { + h.cmdList = append(h.cmdList, cmd) + } // whenever we add a new command, reset the current // pointer to the "beginning" of the list -- cgit