AlecAivazis / survey

A golang library for building interactive and accessible prompts with full support for windows and posix terminals.
MIT License
4.07k stars 351 forks source link

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

Closed russellseymour closed 2 years ago

russellseymour commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

Thank you for the detailed report! This looks like a duplicate of https://github.com/AlecAivazis/survey/issues/368

Semi-related: https://github.com/AlecAivazis/survey/issues/270 https://github.com/AlecAivazis/survey/issues/347