1
0
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:
Jesse Duffield
2020-10-07 21:19:38 +11:00
parent ba4c3e5bc4
commit 79e59d5460
15 changed files with 84 additions and 64 deletions

View File

@ -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
}