do not /add files that fail to decode

This commit is contained in:
Paul Gauthier 2023-07-05 21:00:10 -07:00
parent c6e71b443b
commit c2c80bbd3c
2 changed files with 6 additions and 4 deletions

View file

@ -252,6 +252,8 @@ class Commands:
for matched_file in matched_files:
abs_file_path = os.path.abspath(os.path.join(self.coder.root, matched_file))
if abs_file_path not in self.coder.abs_fnames:
content = self.io.read_text(abs_file_path)
if content is not None:
self.coder.abs_fnames.add(abs_file_path)
self.io.tool_output(f"Added {matched_file} to the chat")
added_fnames.append(matched_file)

View file

@ -140,7 +140,7 @@ class InputOutput:
with open(filename, "r", encoding=self.encoding) as f:
return f.read()
except (FileNotFoundError, UnicodeError) as e:
self.tool_error(str(e))
self.tool_error(f"{filename}: {e}")
return
def get_input(self, root, rel_fnames, addable_rel_fnames, commands):