From a98a037e3f0b51b8a992bfdd4c50debb70a53553 Mon Sep 17 00:00:00 2001 From: Skip Baney Date: Wed, 21 Sep 2022 14:20:48 -0500 Subject: [PATCH] Show transformed answer after submitting input (#450) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Mislav Marohnić --- input.go | 9 +-------- survey_test.go | 1 + 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/input.go b/input.go index dbc7c08c..2fddff5b 100644 --- a/input.go +++ b/input.go @@ -207,20 +207,13 @@ func (i *Input) Prompt(config *PromptConfig) (interface{}, error) { } func (i *Input) Cleanup(config *PromptConfig, val interface{}) error { - // use the default answer when cleaning up the prompt if necessary - ans := i.answer - if ans == "" && i.Default != "" { - ans = i.Default - } - - // render the cleanup return i.Render( InputQuestionTemplate, InputTemplateData{ Input: *i, ShowAnswer: true, Config: config, - Answer: ans, + Answer: val.(string), }, ) } diff --git a/survey_test.go b/survey_test.go index ff8a158b..1b1ea419 100644 --- a/survey_test.go +++ b/survey_test.go @@ -380,6 +380,7 @@ func TestAsk(t *testing.T) { func(c expectConsole) { c.ExpectString("What is your name?") c.SendLine("Johnny Appleseed") + c.ExpectString("What is your name? johnny appleseed") c.ExpectEOF() }, map[string]interface{}{