mirror of
https://github.com/junegunn/fzf.git
synced 2025-08-11 10:12:01 -07:00
Fix deadlock on exit
This commit is contained in:
@@ -133,6 +133,7 @@ type Terminal struct {
|
|||||||
count int
|
count int
|
||||||
progress int
|
progress int
|
||||||
reading bool
|
reading bool
|
||||||
|
running bool
|
||||||
failed *string
|
failed *string
|
||||||
jumping jumpMode
|
jumping jumpMode
|
||||||
jumpLabels string
|
jumpLabels string
|
||||||
@@ -505,6 +506,7 @@ func NewTerminal(opts *Options, eventBox *util.EventBox) *Terminal {
|
|||||||
ansi: opts.Ansi,
|
ansi: opts.Ansi,
|
||||||
tabstop: opts.Tabstop,
|
tabstop: opts.Tabstop,
|
||||||
reading: true,
|
reading: true,
|
||||||
|
running: true,
|
||||||
failed: nil,
|
failed: nil,
|
||||||
jumping: jumpDisabled,
|
jumping: jumpDisabled,
|
||||||
jumpLabels: opts.JumpLabels,
|
jumpLabels: opts.JumpLabels,
|
||||||
@@ -1843,6 +1845,8 @@ func (t *Terminal) exit(getCode func() int) {
|
|||||||
}
|
}
|
||||||
// prof.Stop()
|
// prof.Stop()
|
||||||
t.killPreview(code)
|
t.killPreview(code)
|
||||||
|
t.running = false
|
||||||
|
t.mutex.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Loop is called to start Terminal I/O
|
// Loop is called to start Terminal I/O
|
||||||
@@ -2068,10 +2072,16 @@ func (t *Terminal) Loop() {
|
|||||||
go func() {
|
go func() {
|
||||||
var focusedIndex int32 = minItem.Index()
|
var focusedIndex int32 = minItem.Index()
|
||||||
var version int64 = -1
|
var version int64 = -1
|
||||||
for {
|
running := true
|
||||||
|
for running {
|
||||||
t.reqBox.Wait(func(events *util.Events) {
|
t.reqBox.Wait(func(events *util.Events) {
|
||||||
defer events.Clear()
|
defer events.Clear()
|
||||||
t.mutex.Lock()
|
t.mutex.Lock()
|
||||||
|
if !t.running {
|
||||||
|
running = false
|
||||||
|
t.mutex.Unlock()
|
||||||
|
return
|
||||||
|
}
|
||||||
for req, value := range *events {
|
for req, value := range *events {
|
||||||
switch req {
|
switch req {
|
||||||
case reqPrompt:
|
case reqPrompt:
|
||||||
|
Reference in New Issue
Block a user