Exit application if input terminal has closed

Bump tcell to get access to event error information, and to propagate
input EOF errors as event errors.

Fixes #2569
Fixes #2148
This commit is contained in:
Zachary Yedidia
2023-03-20 16:17:43 -04:00
parent 9c2ce486a5
commit 5739daffc8
3 changed files with 23 additions and 1 deletions

View File

@@ -3,6 +3,7 @@ package main
import (
"flag"
"fmt"
"io"
"io/ioutil"
"log"
"os"
@@ -448,6 +449,25 @@ func DoEvent() {
os.Exit(0)
}
if e, ok := event.(*tcell.EventError); ok {
log.Println("tcell event error: ", e.Error())
if e.Err() == io.EOF {
// shutdown due to terminal closing/becoming inaccessible
for _, b := range buffer.OpenBuffers {
if !b.Modified() {
b.Fini()
}
}
if screen.Screen != nil {
screen.Screen.Fini()
}
os.Exit(0)
}
return
}
ulua.Lock.Lock()
// if event != nil {
if action.InfoBar.HasPrompt {