Skip to content

Commit b9dd3c8

Browse files
authored
BUGFIX: fix prompt for enter on Windows (#301)
* fix prompt for enter func * update comments
1 parent 502e8bb commit b9dd3c8

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

internal/pkg/print/print.go

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -138,22 +138,15 @@ func (p *Printer) PromptForConfirmation(prompt string) error {
138138

139139
// Prompts the user for confirmation by pressing Enter.
140140
//
141-
// Returns nil only if the user (explicitly) press directly enter.
142-
// Returns ErrAborted if the user press anything else before pressing enter.
141+
// Returns nil if the user presses Enter.
143142
func (p *Printer) PromptForEnter(prompt string) error {
144-
reader := bufio.NewReaderSize(p.Cmd.InOrStdin(), 1)
145-
143+
reader := bufio.NewReader(p.Cmd.InOrStdin())
146144
p.Cmd.PrintErr(prompt)
147-
answer, err := reader.ReadByte()
145+
_, err := reader.ReadString('\n')
148146
if err != nil {
149147
return fmt.Errorf("read user response: %w", err)
150148
}
151-
152-
// ASCII code for Enter (newline) is 10.
153-
if answer == 10 {
154-
return nil
155-
}
156-
return errAborted
149+
return nil
157150
}
158151

159152
// Shows the content in the command's stdout using the "less" command

0 commit comments

Comments
 (0)