diff --git a/survey.go b/survey.go index aad73bbe..15f92aa2 100644 --- a/survey.go +++ b/survey.go @@ -256,7 +256,8 @@ func WithShowCursor(ShowCursor bool) AskOpt { } } -// WithHideCharacter sets the default character shown instead of the password for password inputs +// WithHideCharacter sets the default character shown instead of the password for password inputs. +// A space can be used to hide the password length by not printing anything. func WithHideCharacter(char rune) AskOpt { return func(options *AskOptions) error { // set the hide character diff --git a/terminal/runereader.go b/terminal/runereader.go index 998e415e..3fb80bbd 100644 --- a/terminal/runereader.go +++ b/terminal/runereader.go @@ -26,6 +26,10 @@ func (rr *RuneReader) printChar(char rune, mask rune) error { _, err := fmt.Fprintf(rr.stdio.Out, "%c", char) return err } + // if the mask is a space, don't print anything + if mask == ' ' { + return nil + } // otherwise print the mask we were given _, err := fmt.Fprintf(rr.stdio.Out, "%c", mask) return err