handle ui suspend/resume errors

cc #592
This commit is contained in:
Gokcehan 2021-03-28 18:54:40 +03:00
parent 06bf58851b
commit 73be81595e
2 changed files with 15 additions and 6 deletions

13
app.go
View File

@ -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()

8
ui.go
View File

@ -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() {