diff --git a/pkg/terminal/command.go b/pkg/terminal/command.go index 86b8779f..d661daef 100644 --- a/pkg/terminal/command.go +++ b/pkg/terminal/command.go @@ -1754,7 +1754,7 @@ func setBreakpoint(t *Term, ctx callContext, tracepoint bool, argstr string) ([] if findLocErr != nil && shouldAskToSuspendBreakpoint(t) { fmt.Fprintf(os.Stderr, "Command failed: %s\n", findLocErr.Error()) findLocErr = nil - answer, err := yesno(t.line, "Set a suspended breakpoint (Delve will try to set this breakpoint when a plugin is loaded) [Y/n]?") + answer, err := yesno(t.line, "Set a suspended breakpoint (Delve will try to set this breakpoint when a plugin is loaded) [Y/n]?", "yes") if err != nil { return nil, err } diff --git a/pkg/terminal/terminal.go b/pkg/terminal/terminal.go index 581087ef..4b62625e 100644 --- a/pkg/terminal/terminal.go +++ b/pkg/terminal/terminal.go @@ -432,13 +432,16 @@ func (t *Term) promptForInput() (string, error) { return l, nil } -func yesno(line *liner.State, question string) (bool, error) { +func yesno(line *liner.State, question, defaultAnswer string) (bool, error) { for { answer, err := line.Prompt(question) if err != nil { return false, err } answer = strings.ToLower(strings.TrimSpace(answer)) + if answer == "" { + answer = defaultAnswer + } switch answer { case "n", "no": return false, nil @@ -469,7 +472,7 @@ func (t *Term) handleExit() (int, error) { if err != nil { if isErrProcessExited(err) { if t.client.IsMulticlient() { - answer, err := yesno(t.line, "Remote process has exited. Would you like to kill the headless instance? [Y/n] ") + answer, err := yesno(t.line, "Remote process has exited. Would you like to kill the headless instance? [Y/n] ", "yes") if err != nil { return 2, io.EOF } @@ -495,7 +498,7 @@ func (t *Term) handleExit() (int, error) { doDetach := true if t.client.IsMulticlient() { - answer, err := yesno(t.line, "Would you like to kill the headless instance? [Y/n] ") + answer, err := yesno(t.line, "Would you like to kill the headless instance? [Y/n] ", "yes") if err != nil { return 2, io.EOF } @@ -505,7 +508,7 @@ func (t *Term) handleExit() (int, error) { if doDetach { kill := true if t.client.AttachedToExistingProcess() { - answer, err := yesno(t.line, "Would you like to kill the process? [Y/n] ") + answer, err := yesno(t.line, "Would you like to kill the process? [Y/n] ", "yes") if err != nil { return 2, io.EOF }