diff --git a/aider/commands.py b/aider/commands.py index fe70dbe75..5a73b2411 100644 --- a/aider/commands.py +++ b/aider/commands.py @@ -151,6 +151,7 @@ class Commands: assert cmd.startswith("/") cmd = cmd[1:] + cmd = cmd.replace("-", "_") fun = getattr(self, f"completions_{cmd}", None) if not fun: return @@ -510,7 +511,7 @@ class Commands: fname = f'"{fname}"' return fname - def completions_read(self): + def completions_read_only(self): return self.completions_add() def completions_add(self): diff --git a/aider/io.py b/aider/io.py index 502c9ae76..093b6403e 100644 --- a/aider/io.py +++ b/aider/io.py @@ -105,8 +105,10 @@ class AutoCompleter(Completer): cmd = words[0] partial = words[-1].lower() - if cmd not in self.command_names: + matches, _, _ = self.commands.matching_commands(cmd) + if len(matches) != 1: return + cmd = matches[0] if cmd not in self.command_completions: candidates = self.commands.get_completions(cmd) diff --git a/tests/basic/test_io.py b/tests/basic/test_io.py index 511cd7355..89e759dca 100644 --- a/tests/basic/test_io.py +++ b/tests/basic/test_io.py @@ -34,6 +34,7 @@ class TestInputOutput(unittest.TestCase): Path(fname).write_text("def hello(): pass\n") autocompleter = AutoCompleter(root, rel_fnames, addable_rel_fnames, commands, "utf-8") + autocompleter.tokenize() dump(autocompleter.words) self.assertEqual(autocompleter.words, set(rel_fnames + [("hello", "`hello`")]))