From 6cd8c7a33af83624870cc3d7433920293de5b6ec Mon Sep 17 00:00:00 2001 From: Mathieu Frenette Date: Tue, 25 Jul 2023 15:30:40 -0400 Subject: [PATCH] Fix multi-line clean-up issue --- multiline.go | 10 +--------- terminal/cursor.go | 4 ++-- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/multiline.go b/multiline.go index bff9622f..2a045f8e 100644 --- a/multiline.go +++ b/multiline.go @@ -2,8 +2,6 @@ package survey import ( "strings" - - "github.com/AlecAivazis/survey/v2/terminal" ) type Multiline struct { @@ -70,13 +68,7 @@ func (i *Multiline) Prompt(config *PromptConfig) (interface{}, error) { if string(line) == "" { if emptyOnce { - numLines := len(multiline) + 2 - cursor.PreviousLine(numLines) - for j := 0; j < numLines; j++ { - terminal.EraseLine(i.Stdio().Out, terminal.ERASE_LINE_ALL) - cursor.NextLine(1) - } - cursor.PreviousLine(numLines) + cursor.PreviousLine(3) break } emptyOnce = true diff --git a/terminal/cursor.go b/terminal/cursor.go index 75117e08..6abb3ed8 100644 --- a/terminal/cursor.go +++ b/terminal/cursor.go @@ -47,7 +47,7 @@ func (c *Cursor) Back(n int) error { // NextLine moves cursor to beginning of the line n lines down. func (c *Cursor) NextLine(n int) error { - if err := c.Down(1); err != nil { + if err := c.Down(n); err != nil { return err } return c.HorizontalAbsolute(0) @@ -55,7 +55,7 @@ func (c *Cursor) NextLine(n int) error { // PreviousLine moves cursor to beginning of the line n lines up. func (c *Cursor) PreviousLine(n int) error { - if err := c.Up(1); err != nil { + if err := c.Up(n); err != nil { return err } return c.HorizontalAbsolute(0)