Defer resetting multi-selection on reload

This commit is contained in:
Junegunn Choi
2019-12-09 21:32:58 +09:00
parent af1a5f130b
commit 2b725a4db5
4 changed files with 41 additions and 10 deletions

View File

@@ -112,3 +112,13 @@ func DurWithin(
func IsTty() bool {
return isatty.IsTerminal(os.Stdin.Fd())
}
// Once returns a function that returns the specified boolean value only once
func Once(nextResponse bool) func() bool {
state := nextResponse
return func() bool {
prevState := state
state = false
return prevState
}
}