From 7e19b684263629998d9757a0a37341a1b46431aa Mon Sep 17 00:00:00 2001 From: Dmitry Maluka Date: Thu, 13 Aug 2020 07:38:50 +0200 Subject: [PATCH] Avoid duplicate entries in history (#1822) --- internal/info/infobuffer.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/internal/info/infobuffer.go b/internal/info/infobuffer.go index 6489232b..a3b4e368 100644 --- a/internal/info/infobuffer.go +++ b/internal/info/infobuffer.go @@ -145,6 +145,14 @@ func (i *InfoBuf) DonePrompt(canceled bool) { i.PromptCallback(resp, false) h := i.History[i.PromptType] h[len(h)-1] = resp + + // avoid duplicates + for j := len(h) - 2; j >= 0; j-- { + if h[j] == h[len(h)-1] { + i.History[i.PromptType] = append(h[:j], h[j+1:]...) + break + } + } } // i.PromptCallback = nil }