mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-29 16:54:59 +00:00
fixed file not found in autocompleter, issue #30
This commit is contained in:
parent
4373006137
commit
5d18ebd724
2 changed files with 8 additions and 5 deletions
|
@ -39,8 +39,11 @@ class AutoCompleter(Completer):
|
|||
self.words.add(rel_fname)
|
||||
|
||||
fname = os.path.join(root, rel_fname)
|
||||
try:
|
||||
with open(fname, "r") as f:
|
||||
content = f.read()
|
||||
except FileNotFoundError:
|
||||
continue
|
||||
try:
|
||||
lexer = guess_lexer_for_filename(fname, content)
|
||||
except ClassNotFound:
|
||||
|
|
|
@ -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__":
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue