fix: Update confirm_ask function in aider/io.py

This commit is contained in:
Paul Gauthier (aider) 2024-08-23 16:14:59 -07:00
parent 70f32ed7a2
commit 7805aafe0a

View file

@ -371,12 +371,7 @@ class InputOutput:
def confirm_ask(self, question, default="y", subject=None, explicit_yes_required=False): def confirm_ask(self, question, default="y", subject=None, explicit_yes_required=False):
self.num_user_asks += 1 self.num_user_asks += 1
if default == "y": question += " (Y)es/(N)o/(A)ll/(S)kip all [Y]: "
question += " [Y/n] "
elif default == "n":
question += " [y/N] "
else:
question += " [y/n] "
if subject: if subject:
self.tool_output() self.tool_output()
@ -394,12 +389,12 @@ class InputOutput:
else: else:
style = dict() style = dict()
def is_yesno(text): def is_valid_response(text):
return "yes".startswith(text.lower()) or "no".startswith(text.lower()) return text.lower()[0] in ['y', 'n', 'a', 's', '']
validator = Validator.from_callable( validator = Validator.from_callable(
is_yesno, is_valid_response,
error_message="Answer yes or no.", error_message="Please answer Yes, No, All, or Skip all.",
move_cursor_to_end=True, move_cursor_to_end=True,
) )
@ -413,13 +408,15 @@ class InputOutput:
style=Style.from_dict(style), style=Style.from_dict(style),
validator=validator, validator=validator,
) )
if not res and default: if not res:
res = default res = "y" # Default to Yes if no input
res = res.lower().strip() res = res.lower()[0]
is_yes = res in ("y", "yes") is_yes = res in ("y", "a")
is_all = res == "a"
is_skip = res == "s"
hist = f"{question.strip()} {'y' if is_yes else 'n'}" hist = f"{question.strip()} {res}"
self.append_chat_history(hist, linebreak=True, blockquote=True) self.append_chat_history(hist, linebreak=True, blockquote=True)
return is_yes return is_yes