mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-04 19:55:00 +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
|
@ -750,6 +750,7 @@ 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:
|
||||||
|
try:
|
||||||
if self.prompt_session:
|
if self.prompt_session:
|
||||||
res = self.prompt_session.prompt(
|
res = self.prompt_session.prompt(
|
||||||
question,
|
question,
|
||||||
|
@ -758,6 +759,10 @@ class InputOutput:
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
res = input(question)
|
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,6 +817,7 @@ class InputOutput:
|
||||||
elif self.yes is False:
|
elif self.yes is False:
|
||||||
res = "no"
|
res = "no"
|
||||||
else:
|
else:
|
||||||
|
try:
|
||||||
if self.prompt_session:
|
if self.prompt_session:
|
||||||
res = self.prompt_session.prompt(
|
res = self.prompt_session.prompt(
|
||||||
question + " ",
|
question + " ",
|
||||||
|
@ -821,6 +827,9 @@ class InputOutput:
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
res = input(question + " ")
|
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