mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-03 03:05:00 +00:00
fix: Improve input validation and handling in InputOutput.user_confirm
This commit is contained in:
parent
231e962c7f
commit
0b33892137
1 changed files with 15 additions and 17 deletions
32
aider/io.py
32
aider/io.py
|
@ -419,11 +419,6 @@ class InputOutput:
|
||||||
return text.lower() in valid_responses
|
return text.lower() in valid_responses
|
||||||
|
|
||||||
error_message = f"Please answer with one of: {', '.join(valid_responses)}"
|
error_message = f"Please answer with one of: {', '.join(valid_responses)}"
|
||||||
validator = Validator.from_callable(
|
|
||||||
is_valid_response,
|
|
||||||
error_message=error_message,
|
|
||||||
move_cursor_to_end=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
if self.yes is True:
|
if self.yes is True:
|
||||||
res = "n" if explicit_yes_required else "y"
|
res = "n" if explicit_yes_required else "y"
|
||||||
|
@ -433,23 +428,26 @@ class InputOutput:
|
||||||
res = group.preference
|
res = group.preference
|
||||||
self.user_input(f"{question}{res}", log_only=False)
|
self.user_input(f"{question}{res}", log_only=False)
|
||||||
else:
|
else:
|
||||||
res = prompt(
|
while True:
|
||||||
question,
|
res = prompt(
|
||||||
style=Style.from_dict(style),
|
question,
|
||||||
validator=validator,
|
style=Style.from_dict(style),
|
||||||
)
|
validator=validator,
|
||||||
if not res:
|
)
|
||||||
res = "y" # Default to Yes if no input
|
if not res:
|
||||||
|
res = "y" # Default to Yes if no input
|
||||||
|
break
|
||||||
|
# todo: break if res.lower() is a prefix a `valid_responses`
|
||||||
|
|
||||||
res = res.lower()
|
res = res.lower()[0]
|
||||||
|
|
||||||
if explicit_yes_required:
|
if explicit_yes_required:
|
||||||
is_yes = res == "yes"
|
is_yes = res == "y"
|
||||||
else:
|
else:
|
||||||
is_yes = res in ("yes", "all")
|
is_yes = res in ("y", "a")
|
||||||
|
|
||||||
is_all = res == "all" and group is not None and not explicit_yes_required
|
is_all = res == "a" and group is not None and not explicit_yes_required
|
||||||
is_skip = res == "skip" and group is not None
|
is_skip = res == "s" and group is not None
|
||||||
|
|
||||||
if group:
|
if group:
|
||||||
if is_all and not explicit_yes_required:
|
if is_all and not explicit_yes_required:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue