Pressing "delete" (non-Mac) sends EOF to init questionnaire.
On a non-Mac computer, pressing the delete key results in an EOF being sent to the zero init questionnaire prompt:
✔ Production Frontend Host Name (e.g. app.): app-20-09-14.█
ERROR[2020-09-14T09:46:22-07:00] ❗ Exiting prompt: EOF
I started looking into this a bit.
We use github.com/manifoldco/promptui; but I'm not sure if the bug lies in that library, or in the readline library it uses: github.com/chzyer/readline.
Sorry, I need to clarify that a bit.
There is a bug in zero where we interpret a delete as EOF.
This specific bug doesn't occur in promptui.
Here's a small demo:
package main
import (
"fmt"
"github.com/manifoldco/promptui"
)
func main() {
prompt := promptui.Prompt{
Label: "String",
Validate: nil,
}
result, _ := prompt.Run()
fmt.Printf("Result: %q\n", result)
}
And here's the session where I type fooo, then left-arrow twice, then delete:
↳ go run main.go
✔ String: fo█o
Result: ""
So there appears to be a bug in promptui; although it manifests differently than it does in zero.
I'm able to reproduce this with Readline like so:
package main
import (
"fmt"
"github.com/chzyer/readline"
"github.com/manifoldco/promptui"
"os"
)
func main() {
c := &readline.Config{
HistoryLimit: -1,
UniqueEditLine: true,
}
err := c.Init()
if err != nil {
panic(err)
}
rl, err := readline.NewEx(c)
if err != nil {
panic(err)
}
prompt := promptui.Prompt{
Label: "Text entry",
Default: "Delete me",
AllowEdit: true,
}
for {
_, err := rl.Readline()
if err != nil {
fmt.Printf("Error in readline: %v\n", err)
os.Exit(1)
break
}
}
fmt.Print("Good!")
os.Exit(0)
}
And then running the program, deleting all text at the prompt and pressing ctrl+D or delete:
↳ ./promptui-test
Error in readline: EOF