Skip to content

Commit

Permalink
call Fini when find done
Browse files Browse the repository at this point in the history
  • Loading branch information
tjmtmmnk committed Dec 1, 2020
1 parent 703ab69 commit fd4b878
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions fuzzyfinder.go
Original file line number Diff line number Diff line change
Expand Up @@ -640,10 +640,6 @@ func (f *finder) find(slice interface{}, itemFunc func(i int) string, opts []Opt
err := f.readKey()
switch {
case err == ErrAbort:
if !isInTesting() {
f.term.Screen().Fini()
}

return nil, ErrAbort
case err == errEntered:
f.stateMu.RLock()
Expand Down Expand Up @@ -689,6 +685,10 @@ func Find(slice interface{}, itemFunc func(i int) string, opts ...Option) (int,

func (f *finder) Find(slice interface{}, itemFunc func(i int) string, opts ...Option) (int, error) {
res, err := f.find(slice, itemFunc, opts)
if !isInTesting() {
f.term.Screen().Fini()
}

if err != nil {
return 0, err
}
Expand All @@ -703,7 +703,11 @@ func FindMulti(slice interface{}, itemFunc func(i int) string, opts ...Option) (

func (f *finder) FindMulti(slice interface{}, itemFunc func(i int) string, opts ...Option) ([]int, error) {
opts = append(opts, withMulti())
return f.find(slice, itemFunc, opts)
res, err := f.find(slice, itemFunc, opts)
if !isInTesting() {
f.term.Screen().Fini()
}
return res, err
}

func isInTesting() bool {
Expand Down

0 comments on commit fd4b878

Please sign in to comment.