From ddef8c24995b4fa097c1477c724e1f4639a4f8a7 Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Fri, 21 Mar 2025 09:19:13 -0700 Subject: [PATCH] refactor: Add CommandCompletionException for autocompletion handling --- aider/commands.py | 9 ++++++--- aider/io.py | 9 ++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/aider/commands.py b/aider/commands.py index 47829aa04..4ded7fe8a 100644 --- a/aider/commands.py +++ b/aider/commands.py @@ -1089,13 +1089,16 @@ class Commands: ) def completions_ask(self): - raise NotImplementedError("Use normal autocompleter") + from aider.io import CommandCompletionException + raise CommandCompletionException() def completions_code(self): - raise NotImplementedError("Use normal autocompleter") + from aider.io import CommandCompletionException + raise CommandCompletionException() def completions_architect(self): - raise NotImplementedError("Use normal autocompleter") + from aider.io import CommandCompletionException + raise CommandCompletionException() def cmd_ask(self, args): """Ask questions about the code base without editing any files. If no prompt provided, switches to ask mode.""" # noqa diff --git a/aider/io.py b/aider/io.py index f7ffa3306..ffb364e23 100644 --- a/aider/io.py +++ b/aider/io.py @@ -187,9 +187,12 @@ class AutoCompleter(Completer): return if text[0] == "/": - # catch and handle here; make a purpose built exception for this. ai! - yield from self.get_command_completions(document, complete_event, text, words) - return + try: + yield from self.get_command_completions(document, complete_event, text, words) + return + except CommandCompletionException: + # Fall through to normal completion + pass candidates = self.words candidates.update(set(self.fname_to_rel_fnames))