Skip to content

Commit

Permalink
Prevent infinite loop when using on-quit (#1856)
Browse files Browse the repository at this point in the history
  • Loading branch information
joelim-work authored Nov 17, 2024
1 parent f0dddcc commit 68a29c9
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type app struct {
menuCompInd int
selectionOut []string
watch *watch
quitting bool
}

func newApp(ui *ui, nav *nav) *app {
Expand Down Expand Up @@ -66,6 +67,14 @@ func newApp(ui *ui, nav *nav) *app {
}

func (app *app) quit() {
// Using synchronous shell commands for `on-quit` can cause this to be
// called again, so a guard variable is introduced here to prevent an
// infinite loop.
if app.quitting {
return
}
app.quitting = true

onQuit(app)

if gOpts.history {
Expand Down

0 comments on commit 68a29c9

Please sign in to comment.