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

Previous terminal line is removed when answer is string longer than 80 chars #347

Open
dmartin35 opened this issue Apr 7, 2021 · 1 comment
Labels

Comments

@dmartin35
Copy link
Contributor

When prompting for a answer, if the response contains 80+ characters, the previous line in the terminal disappear / is removed

What operating system and terminal are you using?
seen on mac os x with default terminal and vscode terminal

An example that showcases the bug.

package main

import (
	"fmt"

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

func main() {
	fmt.Println("This message should not be removed even if anwser has length >= 80 chars")

	var (
		r1 string
	)

	_ = survey.AskOne(&survey.Input{
		Message: "Enter a very long response",
	}, &r1)

	fmt.Println("response: ", r1)

}

What did you expect to see?

$ go run question.go 
This message should not be removed even if anwser has length >= 80 chars
? Enter a very long response 01234567890123456789012345678901234567890123456789012345678901234567890123456789
response:  01234567890123456789012345678901234567890123456789012345678901234567890123456789

What did you see instead?

$ go run question.go 
? Enter a very long response 01234567890123456789012345678901234567890123456789012345678901234567890123456789
response:  01234567890123456789012345678901234567890123456789012345678901234567890123456789
@dmartin35 dmartin35 added the Bug label Apr 7, 2021
@dmartin35
Copy link
Contributor Author

I have added a runtime stack trace , when the

func (c *Cursor) PreviousLine(n int) {
function is called

runtime/debug.Stack(0x24, 0x0, 0x0)
        /usr/local/Cellar/go/1.15.3/libexec/src/runtime/debug/stack.go:24 +0x9f
runtime/debug.PrintStack()
        /usr/local/Cellar/go/1.15.3/libexec/src/runtime/debug/stack.go:16 +0x25
github.com/AlecAivazis/survey/v2/terminal.(*Cursor).PreviousLine(0xc0001e57e0, 0x1)
        /Users/dmartin/go/src/github.com/AlecAivazis/survey/terminal/cursor.go:58 +0x157
github.com/AlecAivazis/survey/v2.(*Renderer).resetPrompt(0xc0001d4000, 0x1)
        /Users/dmartin/go/src/github.com/AlecAivazis/survey/renderer.go:115 +0x205
github.com/AlecAivazis/survey/v2.(*Renderer).Render(0xc0001d4000, 0x118978c, 0x493, 0x1171f00, 0xc0001b1040, 0x0, 0x0)
        /Users/dmartin/go/src/github.com/AlecAivazis/survey/renderer.go:75 +0xa8
github.com/AlecAivazis/survey/v2.(*Input).OnChange(0xc0001d4000, 0xc000000073, 0xc0001d6048, 0x0, 0x0, 0x0)
        /Users/dmartin/go/src/github.com/AlecAivazis/survey/input.go:119 +0x235
github.com/AlecAivazis/survey/v2.(*Input).Prompt(0xc0001d4000, 0xc0001d6048, 0x0, 0x0, 0x0, 0x0)
        /Users/dmartin/go/src/github.com/AlecAivazis/survey/input.go:169 +0x2fa
github.com/AlecAivazis/survey/v2.Ask(0xc0001e5eb0, 0x1, 0x1, 0x114faa0, 0xc000188430, 0x0, 0x0, 0x0, 0x0, 0x118a290)
        /Users/dmartin/go/src/github.com/AlecAivazis/survey/survey.go:295 +0x55e
github.com/AlecAivazis/survey/v2.AskOne(0x11b3120, 0xc0001d4000, 0x114faa0, 0xc000188430, 0x0, 0x0, 0x0, 0x1005dc5, 0xc00006c058)
        /Users/dmartin/go/src/github.com/AlecAivazis/survey/survey.go:238 +0x12d
main.main()

don't know if that could help for investigation

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

1 participant