From 2b725a4db5e973d7ce90d1ac0996dcfd3c3f0116 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Mon, 9 Dec 2019 21:32:58 +0900 Subject: Defer resetting multi-selection on reload --- src/util/util.go | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/util/util.go') diff --git a/src/util/util.go b/src/util/util.go index 95c4e1b4..0aa1d804 100644 --- a/src/util/util.go +++ b/src/util/util.go @@ -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 + } +} -- cgit v1.2.3