diff --git a/aider/io.py b/aider/io.py index 3ee5b8317..41299ae2a 100644 --- a/aider/io.py +++ b/aider/io.py @@ -39,8 +39,11 @@ class AutoCompleter(Completer): self.words.add(rel_fname) fname = os.path.join(root, rel_fname) - with open(fname, "r") as f: - content = f.read() + try: + with open(fname, "r") as f: + content = f.read() + except FileNotFoundError: + continue try: lexer = guess_lexer_for_filename(fname, content) except ClassNotFound: diff --git a/tests/test_io.py b/tests/test_io.py index 6863384a4..c1350b03a 100644 --- a/tests/test_io.py +++ b/tests/test_io.py @@ -2,7 +2,7 @@ import os import unittest from unittest.mock import patch -from aider.io import InputOutput, AutoCompleter +from aider.io import AutoCompleter, InputOutput class TestInputOutput(unittest.TestCase): @@ -13,11 +13,11 @@ class TestInputOutput(unittest.TestCase): def test_autocompleter_with_non_existent_file(self): root = "" - rel_fnames = ["non_existent_file"] + rel_fnames = ["non_existent_file.txt"] addable_rel_fnames = [] commands = None autocompleter = AutoCompleter(root, rel_fnames, addable_rel_fnames, commands) - self.assertEqual(autocompleter.words, set()) + self.assertEqual(autocompleter.words, set(rel_fnames)) if __name__ == "__main__":