fix: resize if terminal has been resized during running command and fix readline segfault

dev
TorchedSammy 2021-12-06 15:53:51 -04:00
parent 6ac4aa50b3
commit d270e8f66b
Signed by: sammyette
GPG Key ID: 904FC49417B44DCD
1 changed files with 15 additions and 2 deletions

15
main.go
View File

@ -34,6 +34,9 @@ var (
hooks bait.Bait
defaultConfPath string
defaultHistPath string
resized bool
started bool
)
func main() {
@ -167,6 +170,7 @@ func main() {
os.Exit(0)
}
started = true
input:
for interactive {
running = false
@ -174,6 +178,11 @@ input:
lr.SetPrompt(fmtPrompt())
input, err := lr.Read()
if resized {
resized = false
lr.Resize()
}
if err == io.EOF {
// Exit if user presses ^D (ctrl + d)
break
@ -270,8 +279,12 @@ func HandleSignals() {
}
case syscall.SIGWINCH:
hooks.Em.Emit("signals.resize")
if !running && interactive {
if interactive {
if !running && started {
lr.Resize()
} else {
resized = true
}
}
}
}