diff --git a/aider/coder.py b/aider/coder.py index 3a631675d..ad9e19ef7 100755 --- a/aider/coder.py +++ b/aider/coder.py @@ -164,6 +164,8 @@ class Coder: if self.num_control_c >= 2: break self.console.print("[bold red]^C again to quit") + except EOFError: + return def run_loop(self): if self.pretty: @@ -336,6 +338,8 @@ class Coder: for match in self.pattern.finditer(content): _, path, _, _, original, updated = match.groups() + path = path.strip() + if path not in self.fnames: if not Path(path).exists(): question = f"[red bold]Allow creation of new file {path}?" diff --git a/aider/getinput.py b/aider/getinput.py index 30e7267c4..76315146e 100644 --- a/aider/getinput.py +++ b/aider/getinput.py @@ -5,6 +5,12 @@ from prompt_toolkit import prompt from prompt_toolkit.completion import Completer, Completion from prompt_toolkit.history import FileHistory +from rich.console import Console +import sys +import time +import random + + class FileContentCompleter(Completer): def __init__(self, fnames): self.fnames = fnames @@ -20,28 +26,29 @@ class FileContentCompleter(Completer): with open(fname, "r") as f: content = f.read() - for word in re.split(r'\W+', content): + for word in re.split(r"\W+", content): if word.startswith(last_word): yield Completion(word, start_position=-len(last_word)) -from rich.console import Console -import sys -import time -import random +def canned_input(): + console = Console() + + input_line = input() + + console.print("> ", end="", style="green") + for char in input_line: + console.print(char, end="", style="green") + time.sleep(random.uniform(0.01, 0.15)) + console.print() + console.print() + return input_line -console = Console() def get_input(history_file, fnames): if not sys.stdin.isatty(): - input_line = input() - console.print("> ", end="", style="green") - for char in input_line: - console.print(char, end="", style="green", flush=True) - time.sleep(random.uniform(0.05, 0.1)) - console.print() - console.print() - return input_line + return canned_input() + inp = "" multiline_input = False @@ -54,15 +61,12 @@ def get_input(history_file, fnames): else: show = "> " - try: - line = prompt( - show, - completer=completer_instance, - history=FileHistory(history_file), - style=style, - ) - except EOFError: - return + line = prompt( + show, + completer=completer_instance, + history=FileHistory(history_file), + style=style, + ) if line.strip() == "{" and not multiline_input: multiline_input = True continue