[GH-ISSUE #624] Suspending and coming back to previous screen #459

Closed
opened 2026-03-04 01:05:10 +03:00 by kerem · 5 comments
Owner

Originally created by @ankitpokhrel on GitHub (Jun 28, 2021).
Original GitHub issue: https://github.com/rivo/tview/issues/624

Suspending and coming back to previous screen seems broken since recent update.

Given a simple program that launches vim and goes back to previous screen after exit.

package main

import (
	"os"
	"os/exec"

	"github.com/gdamore/tcell/v2"
	"github.com/rivo/tview"
)

func main() {
	app := tview.NewApplication()
	form := tview.NewForm()

	form.SetInputCapture(func(ev *tcell.EventKey) *tcell.EventKey {
		if ev.Key() == tcell.KeyRune {
			if ev.Rune() == 'q' {
				app.Stop()
				os.Exit(0)
			}
		}
		return ev
	})

	form.AddButton("Edit with vim", func() {
		app.Suspend(func() {
			cmd := exec.Command("vim", "/tmp/foo")
			cmd.Stdout = os.Stdout
			cmd.Stdin = os.Stdin
			_ = cmd.Run()
		})
	})

	form.SetBorder(true).SetTitle("Launch vim & go back to main screen after exit, Press 'q' to exit")

	if err := app.SetRoot(form, true).SetFocus(form).Run(); err != nil {
		panic(err)
	}
}

The code above worked as expected before but panics since 36f5c190ea.

panic: EOF

goroutine 1 [running]:
main.main()
	/go/src/tview-dbg/broken/main.go:37 +0x3b7
exit status 2

The cause of the issue can be traced back to this particular change where we are stopping the app app.Stop when handling tcell.EventError in an event loop.
github.com/rivo/tview@29d673af0c/application.go (L373-L375)

Is there anything I am missing?

Originally created by @ankitpokhrel on GitHub (Jun 28, 2021). Original GitHub issue: https://github.com/rivo/tview/issues/624 Suspending and coming back to previous screen seems broken since recent update. Given a simple program that launches vim and goes back to previous screen after exit. ```go package main import ( "os" "os/exec" "github.com/gdamore/tcell/v2" "github.com/rivo/tview" ) func main() { app := tview.NewApplication() form := tview.NewForm() form.SetInputCapture(func(ev *tcell.EventKey) *tcell.EventKey { if ev.Key() == tcell.KeyRune { if ev.Rune() == 'q' { app.Stop() os.Exit(0) } } return ev }) form.AddButton("Edit with vim", func() { app.Suspend(func() { cmd := exec.Command("vim", "/tmp/foo") cmd.Stdout = os.Stdout cmd.Stdin = os.Stdin _ = cmd.Run() }) }) form.SetBorder(true).SetTitle("Launch vim & go back to main screen after exit, Press 'q' to exit") if err := app.SetRoot(form, true).SetFocus(form).Run(); err != nil { panic(err) } } ``` The code above worked as expected before but panics since 36f5c190eaafcadd0c581ab5efd5125db0306c22. ``` panic: EOF goroutine 1 [running]: main.main() /go/src/tview-dbg/broken/main.go:37 +0x3b7 exit status 2 ``` The cause of the issue can be traced back to this particular change where we are stopping the app `app.Stop` when handling `tcell.EventError` in an event loop. https://github.com/rivo/tview/blob/29d673af0ce2281f8b517d1bd14aab453b8fc8ef/application.go#L373-L375 Is there anything I am missing?
kerem closed this issue 2026-03-04 01:05:10 +03:00
Author
Owner

@darkhz commented on GitHub (Aug 5, 2021):

It's broken for me too. Panics with:
panic: read /dev/tty: i/o timeout

<!-- gh-comment-id:893262939 --> @darkhz commented on GitHub (Aug 5, 2021): It's broken for me too. Panics with: `panic: read /dev/tty: i/o timeout`
Author
Owner

@rivo commented on GitHub (Aug 22, 2021):

This appears to be a problem with tcell. I opened an issue there: gdamore/tcell/issues/480

<!-- gh-comment-id:903311440 --> @rivo commented on GitHub (Aug 22, 2021): This appears to be a problem with `tcell`. I opened an issue there: gdamore/tcell/issues/480
Author
Owner

@rivo commented on GitHub (Sep 4, 2021):

@ankitpokhrel & @darkhz Can you please try this with the latest tcell commit and let me know if it works for you?

<!-- gh-comment-id:912961375 --> @rivo commented on GitHub (Sep 4, 2021): @ankitpokhrel & @darkhz Can you please try this with the latest `tcell` commit and let me know if it works for you?
Author
Owner

@darkhz commented on GitHub (Sep 4, 2021):

@rivo Yes, it works well with the commit in the fix480 branch. Thank you very much.

<!-- gh-comment-id:912990912 --> @darkhz commented on GitHub (Sep 4, 2021): @rivo Yes, it works well with the commit in the [fix480](https://github.com/gdamore/tcell/tree/fix480) branch. Thank you very much.
Author
Owner

@ankitpokhrel commented on GitHub (Sep 4, 2021):

@rivo works fine for me too with latest tcell commit. Thank you!

<!-- gh-comment-id:913012097 --> @ankitpokhrel commented on GitHub (Sep 4, 2021): @rivo works fine for me too with latest `tcell` commit. Thank you!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/tview#459
No description provided.