Skip to content
This repository has been archived by the owner on Apr 19, 2024. It is now read-only.

Input question repeated, with answer, after using Select on Windows #384

Closed
russellseymour opened this issue Oct 11, 2021 · 2 comments
Closed
Labels

Comments

@russellseymour
Copy link

russellseymour commented Oct 11, 2021

What operating system and terminal are you using?

Windows 10 and Windows Terminal

An example that showcases the bug.

Reverse the order of the questions in the simple.go example, e.g:

package main

import (
	"fmt"

	"github.com/AlecAivazis/survey/v2"
)

// the questions to ask
var simpleQs = []*survey.Question{
	{
		Name: "color",
		Prompt: &survey.Select{
			Message: "Choose a color:",
			Options: []string{"red", "blue", "green"},
		},
		Validate: survey.Required,
	},
	{
		Name: "name",
		Prompt: &survey.Input{
			Message: "What is your name?",
		},
		Validate:  survey.Required,
		Transform: survey.Title,
	},
}

func main() {
	answers := struct {
		Name  string
		Color string
	}{}

	// ask the question
	err := survey.Ask(simpleQs, &answers)

	if err != nil {
		fmt.Println(err.Error())
		return
	}
	// print the answers
	fmt.Printf("%s chose %s.\n", answers.Name, answers.Color)
}

What did you expect to see?

The following is a screenshot when running the simple example in WSL using the same terminal

image

What did you see instead?

The response seen is as follows:

image

@russellseymour
Copy link
Author

I have an update after some more testing.

When I run my app which is using &survey.Input{} every line is repeated (this is using Windows Terminal)

image

However when run in the terminal for VSCode the original reported issue is seen

image

The preceeding the double input is the one that is a Select input.

@mislav
Copy link
Collaborator

mislav commented Oct 11, 2021

Thank you for the detailed report! This looks like a duplicate of #368

Semi-related: #270 #347

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

No branches or pull requests

2 participants