From 317f2bf976accbf9272215f128b9c129c192546d Mon Sep 17 00:00:00 2001 From: MarvinJWendt Date: Mon, 5 Sep 2022 01:16:36 +0200 Subject: [PATCH] fix(textinput): fixed overwriting the default values --- interactive_textinput_printer.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/interactive_textinput_printer.go b/interactive_textinput_printer.go index 5688d7368..e71745552 100644 --- a/interactive_textinput_printer.go +++ b/interactive_textinput_printer.go @@ -31,25 +31,25 @@ type InteractiveTextInputPrinter struct { } // WithDefaultText sets the default text. -func (p *InteractiveTextInputPrinter) WithDefaultText(text string) *InteractiveTextInputPrinter { +func (p InteractiveTextInputPrinter) WithDefaultText(text string) *InteractiveTextInputPrinter { p.DefaultText = text - return p + return &p } // WithTextStyle sets the text style. -func (p *InteractiveTextInputPrinter) WithTextStyle(style *Style) *InteractiveTextInputPrinter { +func (p InteractiveTextInputPrinter) WithTextStyle(style *Style) *InteractiveTextInputPrinter { p.TextStyle = style - return p + return &p } // WithMultiLine sets the multi line flag. -func (p *InteractiveTextInputPrinter) WithMultiLine(multiLine ...bool) *InteractiveTextInputPrinter { +func (p InteractiveTextInputPrinter) WithMultiLine(multiLine ...bool) *InteractiveTextInputPrinter { p.MultiLine = internal.WithBoolean(multiLine) - return p + return &p } // Show shows the interactive select menu and returns the selected entry. -func (p *InteractiveTextInputPrinter) Show(text ...string) (string, error) { +func (p InteractiveTextInputPrinter) Show(text ...string) (string, error) { // should be the first defer statement to make sure it is executed last // and all the needed cleanup can be done before cancel, exit := internal.NewCancelationSignal() @@ -195,7 +195,7 @@ func (p *InteractiveTextInputPrinter) Show(text ...string) (string, error) { return strings.ReplaceAll(areaText, p.text, ""), nil } -func (p *InteractiveTextInputPrinter) updateArea(area *AreaPrinter) string { +func (p InteractiveTextInputPrinter) updateArea(area *AreaPrinter) string { if !p.MultiLine { p.cursorYPos = 0 }