diff options
author | Joe Lim <50560759+joelim-work@users.noreply.github.com> | 2024-04-07 23:47:49 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-07 15:47:49 +0200 |
commit | ce1211641830029000f7f3c56444dc509487d6b2 (patch) | |
tree | f2fefb84e558d5afdd42950630c3cb65e655cd6e | |
parent | 63815aaa75217dfee0b5fe92defca09fb32ed515 (diff) |
Run `on-quit` when terminal closes (#1681)
-rw-r--r-- | app.go | 6 | ||||
-rw-r--r-- | eval.go | 6 |
2 files changed, 8 insertions, 4 deletions
@@ -64,6 +64,8 @@ func newApp(ui *ui, nav *nav) *app { } func (app *app) quit() { + onQuit(app) + if gOpts.history { if err := app.writeHistory(); err != nil { log.Printf("writing history file: %s", err) @@ -320,10 +322,6 @@ func (app *app) loop() { continue } - if cmd, ok := gOpts.cmds["on-quit"]; ok { - cmd.eval(app, nil) - } - app.quit() app.nav.previewChan <- "" @@ -580,6 +580,12 @@ func onSelect(app *app) { } } +func onQuit(app *app) { + if cmd, ok := gOpts.cmds["on-quit"]; ok { + cmd.eval(app, nil) + } +} + func splitKeys(s string) (keys []string) { for i := 0; i < len(s); { r, w := utf8.DecodeRuneInString(s[i:]) |