mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-01 10:14:59 +00:00
refactor: Handle EOFError gracefully in confirm_ask and prompt_ask methods
This commit is contained in:
parent
d7efbad3df
commit
ff3d2b006f
1 changed files with 26 additions and 17 deletions
43
aider/io.py
43
aider/io.py
|
@ -750,14 +750,19 @@ class InputOutput:
|
||||||
self.user_input(f"{question}{res}", log_only=False)
|
self.user_input(f"{question}{res}", log_only=False)
|
||||||
else:
|
else:
|
||||||
while True:
|
while True:
|
||||||
if self.prompt_session:
|
try:
|
||||||
res = self.prompt_session.prompt(
|
if self.prompt_session:
|
||||||
question,
|
res = self.prompt_session.prompt(
|
||||||
style=style,
|
question,
|
||||||
complete_while_typing=False,
|
style=style,
|
||||||
)
|
complete_while_typing=False,
|
||||||
else:
|
)
|
||||||
res = input(question)
|
else:
|
||||||
|
res = input(question)
|
||||||
|
except EOFError:
|
||||||
|
# Treat EOF (Ctrl+D) as if the user pressed Enter
|
||||||
|
res = default
|
||||||
|
break
|
||||||
|
|
||||||
if not res:
|
if not res:
|
||||||
res = default
|
res = default
|
||||||
|
@ -812,15 +817,19 @@ class InputOutput:
|
||||||
elif self.yes is False:
|
elif self.yes is False:
|
||||||
res = "no"
|
res = "no"
|
||||||
else:
|
else:
|
||||||
if self.prompt_session:
|
try:
|
||||||
res = self.prompt_session.prompt(
|
if self.prompt_session:
|
||||||
question + " ",
|
res = self.prompt_session.prompt(
|
||||||
default=default,
|
question + " ",
|
||||||
style=style,
|
default=default,
|
||||||
complete_while_typing=True,
|
style=style,
|
||||||
)
|
complete_while_typing=True,
|
||||||
else:
|
)
|
||||||
res = input(question + " ")
|
else:
|
||||||
|
res = input(question + " ")
|
||||||
|
except EOFError:
|
||||||
|
# Treat EOF (Ctrl+D) as if the user pressed Enter
|
||||||
|
res = default
|
||||||
|
|
||||||
hist = f"{question.strip()} {res.strip()}"
|
hist = f"{question.strip()} {res.strip()}"
|
||||||
self.append_chat_history(hist, linebreak=True, blockquote=True)
|
self.append_chat_history(hist, linebreak=True, blockquote=True)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue