fix: ensure terminal state is restored after panics in Batch/Sequence commands (#1818)
Co-authored-by: TRAE AI Assistant <trae@bytedance.com> Co-authored-by: Drew Smirnoff <drew@charm.land>
This commit is contained in:
parent
73b79b3737
commit
f3d74b724c
1 changed files with 3 additions and 3 deletions
6
tea.go
6
tea.go
|
|
@ -1394,14 +1394,14 @@ func (p *Program) recoverFromPanic(r interface{}) {
|
|||
}
|
||||
}
|
||||
|
||||
// recoverFromGoPanic recovers from a goroutine panic, prints a stack trace and
|
||||
// signals for the program to be killed and terminal restored to a usable state.
|
||||
// recoverFromGoPanic recovers from a goroutine panic, prints a stack trace,
|
||||
// restores the terminal to a usable state, and signals the program to be killed.
|
||||
func (p *Program) recoverFromGoPanic(r interface{}) {
|
||||
select {
|
||||
case p.errs <- ErrProgramPanic:
|
||||
default:
|
||||
}
|
||||
p.cancel()
|
||||
p.shutdown(true)
|
||||
// We use "\r\n" to ensure the output is formatted even when restoring the
|
||||
// terminal does not work or when raw mode is still active.
|
||||
rec := strings.ReplaceAll(fmt.Sprintf("%s", r), "\n", "\r\n")
|
||||
|
|
|
|||
Loading…
Reference in a new issue