Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prompts filling the terminal width causes bad UI #92

Open
maraino opened this issue Jan 19, 2019 · 2 comments
Open

Prompts filling the terminal width causes bad UI #92

maraino opened this issue Jan 19, 2019 · 2 comments

Comments

@maraino
Copy link

maraino commented Jan 19, 2019

Description

When a prompt and the user input fills the terminal width and the input has to go to the next line, the prompt is written again in a new line.

In a small terminal, the proof of concept bellow will cause multiple lines like:

$ go run longprompt.go
✔ Please enter a long very long answer so it has to go to the next line: abcdefg
✔ Please enter a long very long answer so it has to go to the next line: abcdefg
✔ Please enter a long very long answer so it has to go to the next line: abcdefg
hi

Proof of concept:

package main

import (
	"fmt"

	"github.com/manifoldco/promptui"
)

func main() {

	prompt := promptui.Prompt{
		Label: "Please enter a long very long answer so it has to go to the next line",
	}

	result, err := prompt.Run()
	if err != nil {
		fmt.Printf("Prompt failed %v\n", err)
		return
	}
	fmt.Printf("You choose %q\n", result)
}
@MondayHopscotch
Copy link

MondayHopscotch commented Mar 26, 2019

I am running into the same thing. It looks like for every character that is past the end of the width of the terminal, it prints a new prompt line. In your example, hi were the extra characters, so you got 2 extra lines. I have a much longer string and it's dumping out a ton of lines. (We are expecting users to copy/paste a long string into the terminal)

@shaneharter
Copy link

I ran into this, too. It's being caused by line wrapping in the terminal.

After a little research, there isn't a perfect way to disable this, but I've made the issue better in many (most?) modern terminals by disabling wrapping:

shaneharter@33d9dc1

I've not raised a PR because it seems a bit of a hack

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants