From 73be81595ee2a8c90be2195c7d27d7380788f57c Mon Sep 17 00:00:00 2001 From: Gokcehan Date: Sun, 28 Mar 2021 18:54:40 +0300 Subject: [PATCH] handle ui suspend/resume errors cc #592 --- app.go | 13 +++++++++++-- ui.go | 8 ++++---- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/app.go b/app.go index 7bcef27..3d72a28 100644 --- a/app.go +++ b/app.go @@ -396,8 +396,17 @@ func (app *app) runShell(s string, args []string, prefix string) { cmd.Stderr = os.Stderr app.nav.previewChan <- "" - app.ui.suspend() - defer app.ui.resume() + if err := app.ui.suspend(); err != nil { + log.Printf("suspend: %s", err) + } + defer func() { + if err := app.ui.resume(); err != nil { + app.writeHistory() + os.Remove(gLogPath) + os.Exit(3) + return + } + }() defer app.nav.renew() err = cmd.Run() diff --git a/ui.go b/ui.go index e576e00..e94ffdb 100644 --- a/ui.go +++ b/ui.go @@ -1144,12 +1144,12 @@ func (ui *ui) readExpr() { }() } -func (ui *ui) suspend() { - ui.screen.Suspend() +func (ui *ui) suspend() error { + return ui.screen.Suspend() } -func (ui *ui) resume() { - ui.screen.Resume() +func (ui *ui) resume() error { + return ui.screen.Resume() } func anyKey() {