From 288b412597d68d407bb40dae9ec0ffcff504ed41 Mon Sep 17 00:00:00 2001 From: Alec Aivazis Date: Wed, 18 Nov 2020 12:14:17 -0800 Subject: [PATCH] Fix default input display (#314) * fixed bug prevent default answer from being displayed in Input - fixes #310 * added comments --- input.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/input.go b/input.go index 65d37354..a544b045 100644 --- a/input.go +++ b/input.go @@ -190,13 +190,20 @@ 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: i.answer, + Answer: ans, }, ) }