From 51ec18b711e16d133341c2b1bfef670bef92783b Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Thu, 8 Aug 2024 15:35:35 -0300 Subject: [PATCH] fix: Replace `prompt` with `confirm` for yes/no questions --- aider/io.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/aider/io.py b/aider/io.py index 7a836c10c..7e18a4482 100644 --- a/aider/io.py +++ b/aider/io.py @@ -9,7 +9,7 @@ from prompt_toolkit.enums import EditingMode from prompt_toolkit.history import FileHistory from prompt_toolkit.key_binding import KeyBindings from prompt_toolkit.lexers import PygmentsLexer -from prompt_toolkit.shortcuts import CompleteStyle, PromptSession, prompt +from prompt_toolkit.shortcuts import CompleteStyle, PromptSession, confirm, prompt from prompt_toolkit.styles import Style from pygments.lexers import MarkdownLexer, guess_lexer_for_filename from pygments.token import Token @@ -341,18 +341,20 @@ class InputOutput: self.num_user_asks += 1 if self.yes is True: - res = "yes" + res = True elif self.yes is False: - res = "no" + res = False else: - res = prompt(question + " ", default=default) + res = confirm(question) + + if res: + hist = f"{question.strip()} y" + else: + hist = f"{question.strip()} n" - hist = f"{question.strip()} {res.strip()}" self.append_chat_history(hist, linebreak=True, blockquote=True) - if not res or not res.strip(): - return - return res.strip().lower().startswith("y") + return res def prompt_ask(self, question, default=None): self.num_user_asks += 1