refactor: Add CommandCompletionException for autocompletion handling

This commit is contained in:
Paul Gauthier (aider) 2025-03-21 09:19:13 -07:00
parent c6289c2bea
commit ddef8c2499
2 changed files with 12 additions and 6 deletions

View file

@ -1089,13 +1089,16 @@ class Commands:
) )
def completions_ask(self): def completions_ask(self):
raise NotImplementedError("Use normal autocompleter") from aider.io import CommandCompletionException
raise CommandCompletionException()
def completions_code(self): def completions_code(self):
raise NotImplementedError("Use normal autocompleter") from aider.io import CommandCompletionException
raise CommandCompletionException()
def completions_architect(self): def completions_architect(self):
raise NotImplementedError("Use normal autocompleter") from aider.io import CommandCompletionException
raise CommandCompletionException()
def cmd_ask(self, args): def cmd_ask(self, args):
"""Ask questions about the code base without editing any files. If no prompt provided, switches to ask mode.""" # noqa """Ask questions about the code base without editing any files. If no prompt provided, switches to ask mode.""" # noqa

View file

@ -187,9 +187,12 @@ class AutoCompleter(Completer):
return return
if text[0] == "/": if text[0] == "/":
# catch and handle here; make a purpose built exception for this. ai! try:
yield from self.get_command_completions(document, complete_event, text, words) yield from self.get_command_completions(document, complete_event, text, words)
return return
except CommandCompletionException:
# Fall through to normal completion
pass
candidates = self.words candidates = self.words
candidates.update(set(self.fname_to_rel_fnames)) candidates.update(set(self.fname_to_rel_fnames))