Skip to content

Commit

Permalink
call Fini in find
Browse files Browse the repository at this point in the history
  • Loading branch information
tjmtmmnk committed Dec 13, 2020
1 parent a19c30d commit e37529d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 4 additions & 2 deletions fuzzyfinder.go
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,10 @@ func (f *finder) find(slice interface{}, itemFunc func(i int) string, opts []Opt
return nil, errors.Wrap(err, "failed to initialize the fuzzy finder")
}

if !isInTesting() {
defer f.term.Fini()
}

close(inited)

go func() {
Expand Down Expand Up @@ -704,7 +708,6 @@ 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.Fini()
if err := sendExtraEventFix(); err != nil {
return 0, err
}
Expand All @@ -726,7 +729,6 @@ func (f *finder) FindMulti(slice interface{}, itemFunc func(i int) string, opts
opts = append(opts, withMulti())
res, err := f.find(slice, itemFunc, opts)
if !isInTesting() {
f.term.Fini()
if err := sendExtraEventFix(); err != nil {
return nil, err
}
Expand Down
2 changes: 0 additions & 2 deletions fuzzyfinder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@ func TestFind(t *testing.T) {
}

res := term.GetResult()
term.Fini()
return res
})
})
Expand Down Expand Up @@ -245,7 +244,6 @@ func TestFind_hotReload(t *testing.T) {
}

res := term.GetResult()
term.Fini()
return res
})
}
Expand Down

0 comments on commit e37529d

Please sign in to comment.