aboutsummaryrefslogtreecommitdiffstats
path: root/commands/history.go
diff options
context:
space:
mode:
authorMoritz Poldrack <git@moritz.sh>2022-09-14 18:34:48 +0200
committerRobin Jarry <robin@jarry.cc>2022-09-14 20:51:41 +0200
commit9c11ab21c73cecf80a243d8dfb55b7793da7bb96 (patch)
treed859430fcc7a2c08062af7fea17a8fdfd708783b /commands/history.go
parent94bff9130d4e0a3b93563792f141444b5083fe51 (diff)
downloadaerc-9c11ab21c73cecf80a243d8dfb55b7793da7bb96.tar.gz
history: don't store duplicate entries
Signed-off-by: Moritz Poldrack <git@moritz.sh> Acked-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'commands/history.go')
-rw-r--r--commands/history.go4
1 files changed, 3 insertions, 1 deletions
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