mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-30 03:23:08 +03:00
add some safe goroutines
WIP
This commit is contained in:
@ -14,6 +14,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/fatih/color"
|
||||
"github.com/jesseduffield/termbox-go"
|
||||
)
|
||||
|
||||
// SplitLines takes a multiline string and splits it on newlines
|
||||
@ -360,3 +361,18 @@ func ResolveTemplate(templateStr string, object interface{}) (string, error) {
|
||||
|
||||
return buf.String(), nil
|
||||
}
|
||||
|
||||
// Safe will close termbox if a panic occurs so that we don't end up in a malformed
|
||||
// terminal state
|
||||
func Safe(f func()) {
|
||||
panicking := true
|
||||
defer func() {
|
||||
if panicking {
|
||||
termbox.Close()
|
||||
}
|
||||
}()
|
||||
|
||||
f()
|
||||
|
||||
panicking = false
|
||||
}
|
||||
|
Reference in New Issue
Block a user