Avoid duplicate entries in history (#1822)

This commit is contained in:
Dmitry Maluka 2020-08-13 07:38:50 +02:00 committed by GitHub
parent c5bafbc1c5
commit 7e19b68426
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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
}