From 54aebb7d989e99887aafb549dceebf23992a20c2 Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Fri, 25 Oct 2024 13:23:46 -0700 Subject: [PATCH] feat: add encoding param to watch_source_files with error handling --- aider/watch.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/aider/watch.py b/aider/watch.py index 9594de937..30d6c2e5e 100644 --- a/aider/watch.py +++ b/aider/watch.py @@ -59,7 +59,7 @@ def load_gitignores(gitignore_paths: list[Path]) -> Optional[PathSpec]: def watch_source_files( - directory: str, stop_event=None, gitignores: list[str] = None, ignore_func=None + directory: str, stop_event=None, gitignores: list[str] = None, ignore_func=None, encoding="utf-8" ) -> Set[str]: """ Watch for changes to source files in the given directory and its subdirectories. @@ -98,7 +98,7 @@ def watch_source_files( # Check if file contains AI markers try: - with open(path_abs) as f: + with open(path_abs, encoding=encoding, errors='ignore') as f: content = f.read() import re