AlecAivazis / survey

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

Cursor is sometimes not going back to the start of the line #334

Closed PierreBtz closed 3 years ago

PierreBtz commented 3 years ago

What operating system and terminal are you using?

macOS Big Sur 11.0.1 with iterm2

An example that showcases the bug.

package main

import (
    "fmt"
    "github.com/AlecAivazis/survey/v2"
)

func main() {
    prompt := &survey.Password{
        Message: "password",
    }
    var pass string
    _ = survey.AskOne(prompt, &pass)

    fmt.Print("hello")
}

When running this sample, one can see that after the prompt the cursor stays aligned with the previous prompt text:

Screenshot 2021-02-12 at 16 10 10

What did you expect to see?

The cursor is going back to the beginning of the line.

I tracked the issue to PR #309. I re-ran the previous test by adding a call to c.HorizontalAbsolute(0) (like it's done for Windows) and confirmed this was fixing my issue.

davidji99 commented 3 years ago

I'm experiencing the same sort of issue where multiple outputs creates a staircase effect as mentioned by the OP.

AlecAivazis commented 3 years ago

@PierreBtz - do you mind opening a PR with your fix? I would like to give it a shot but I dont have a lot of time at the moment

PierreBtz commented 3 years ago

@AlecAivazis I opened #335