Run on-quit when terminal closes (#1681)

This commit is contained in:
Joe Lim authored and GitHub committed 2024-04-07 15:47:49 +02:00
1 parent 63815aaa75
commit ce12116418
2 files changed
+8 -4

No files matched your search

+2 -4
View File
@@ -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 <- ""
+6
View File
@@ -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:])