diff options
| author | Junegunn Choi <junegunn.c@gmail.com> | 2019-12-09 21:32:58 +0900 |
|---|---|---|
| committer | Junegunn Choi <junegunn.c@gmail.com> | 2019-12-09 21:32:58 +0900 |
| commit | 2b725a4db5e973d7ce90d1ac0996dcfd3c3f0116 (patch) | |
| tree | c9eea79293181e3049ac974d3f8cc892bd27bf77 /src/util/util.go | |
| parent | af1a5f130bbd2464131ec2ae91c538ace6801a73 (diff) | |
| download | fzf-2b725a4db5e973d7ce90d1ac0996dcfd3c3f0116.tar.gz | |
Defer resetting multi-selection on reload
Diffstat (limited to 'src/util/util.go')
| -rw-r--r-- | src/util/util.go | 10 |
1 files changed, 10 insertions, 0 deletions
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 + } +} |
