[GH-ISSUE #597] app.Stop() and app.Suspend() require an additional keypress before clearing screen #437

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

Originally created by @lukegalea on GitHub (May 6, 2021).
Original GitHub issue: https://github.com/rivo/tview/issues/597

Both when using app.Stop() to exit a tview application, or when using app.Suspend(), I'm finding that a second keypress is required before the user actually "sees" the app stop.

in the trivial example below, a single press of escape should exit the program... but instead, the first press of escape doesn't clear the screen nor exit the program.. but a second keypress of any kind (enter, a second escape.. whatever) does trigger the program closing and the screen clearing.

I've tried seeding the program w/ debug output (fmt.Println) to confirm that app.Stop is being called.. and it is.. it just doesn't have the desired effect.

package main

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

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

	app.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
		if event.Key() == tcell.KeyEsc {
			app.Stop()
		}
		return event
	})

	app.
		SetRoot(tview.NewTextView().SetText("Hello World"), true).
		Run()
}
Originally created by @lukegalea on GitHub (May 6, 2021). Original GitHub issue: https://github.com/rivo/tview/issues/597 Both when using app.Stop() to exit a tview application, or when using app.Suspend(), I'm finding that a second keypress is required before the user actually "sees" the app stop. in the trivial example below, a single press of escape should exit the program... but instead, the first press of escape doesn't clear the screen nor exit the program.. but a second keypress of any kind (enter, a second escape.. whatever) does trigger the program closing and the screen clearing. I've tried seeding the program w/ debug output (fmt.Println) to confirm that app.Stop is being called.. and it is.. it just doesn't have the desired effect. ``` package main import ( "github.com/gdamore/tcell/v2" "github.com/rivo/tview" ) func main() { app := tview.NewApplication() app.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey { if event.Key() == tcell.KeyEsc { app.Stop() } return event }) app. SetRoot(tview.NewTextView().SetText("Hello World"), true). Run() } ```
kerem closed this issue 2026-03-04 01:05:00 +03:00
Author
Owner

@lukegalea commented on GitHub (May 6, 2021):

A colleague has confirmed for me that this is not a problem on OSX. A single press of escape clears the screen and exits the process.,

I've confirmed it to be a problem on multiple linux distros, though.

<!-- gh-comment-id:833889681 --> @lukegalea commented on GitHub (May 6, 2021): A colleague has confirmed for me that this is not a problem on OSX. A single press of escape clears the screen and exits the process., I've confirmed it to be a problem on multiple linux distros, though.
Author
Owner

@mdom commented on GitHub (May 10, 2021):

This bug does also effect OpenBSD 6.8. I'm just running the hello world demo from the README page in a xterm and i need to type another key after Ctrl-C for the application to quit.

<!-- gh-comment-id:836271678 --> @mdom commented on GitHub (May 10, 2021): This bug does also effect OpenBSD 6.8. I'm just running the hello world demo from the README page in a xterm and i need to type another key after Ctrl-C for the application to quit.
Author
Owner

@D54 commented on GitHub (May 10, 2021):

It also affects Linux.
Tried in Alacritty 0.7.2 and Tilix 1.9.4.

<!-- gh-comment-id:837449908 --> @D54 commented on GitHub (May 10, 2021): It also affects Linux. Tried in Alacritty 0.7.2 and Tilix 1.9.4.
Author
Owner

@mdom commented on GitHub (May 11, 2021):

This seems to be the same issue mentioned in gdamore/tcell#452 and #244. Although the work around mentioned #244 does not work on my system.

<!-- gh-comment-id:838041724 --> @mdom commented on GitHub (May 11, 2021): This seems to be the same issue mentioned in gdamore/tcell#452 and #244. Although the work around mentioned #244 does not work on my system.
Author
Owner

@mdom commented on GitHub (May 17, 2021):

This is fixed in gdamore/tcell@8f925d8 and works fine on my machine. Maybe it would be good to update the dependency on tcell to release 2.3.1?

<!-- gh-comment-id:842064874 --> @mdom commented on GitHub (May 17, 2021): This is fixed in gdamore/tcell@8f925d8 and works fine on my machine. Maybe it would be good to update the dependency on tcell to release 2.3.1?
Author
Owner

@D54 commented on GitHub (May 25, 2021):

I can confirm that the current version works perfectly with gdamore/tcell v2.3.3.
c723ed0 solved this issue as well, so it can be closed.

<!-- gh-comment-id:848191784 --> @D54 commented on GitHub (May 25, 2021): I can confirm that the current version works perfectly with gdamore/tcell v2.3.3. c723ed0 solved this issue as well, so it can be closed.
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#437
No description provided.