From 2f8eedded7969c14de96426d6a09d499e933b2be Mon Sep 17 00:00:00 2001 From: asdf Date: Tue, 8 Sep 2020 13:41:52 +1000 Subject: [PATCH] Handle input errors while returning to correct terminal mode --- cui/cui.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cui/cui.go b/cui/cui.go index c3ee14a..1ed29d7 100644 --- a/cui/cui.go +++ b/cui/cui.go @@ -102,6 +102,7 @@ func Getch() rune { func GetLine(prefix string) (string, error) { termios.SetLineMode() + defer termios.SetCharMode() reader := bufio.NewReader(os.Stdin) fmt.Print(prefix) @@ -110,7 +111,6 @@ func GetLine(prefix string) (string, error) { return "", err } - termios.SetCharMode() return text[:len(text)-1], nil }