From b5dbb1d39d1781582d74f768fefe58cb4307a257 Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Sun, 1 Dec 2024 07:28:37 -0800 Subject: [PATCH] refactor: simplify file content check using direct io.read_text and regex search --- aider/watch.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/aider/watch.py b/aider/watch.py index 14f7e3f95..6187e5985 100644 --- a/aider/watch.py +++ b/aider/watch.py @@ -105,11 +105,14 @@ class FileWatcher: # Check if file contains AI markers try: - # ai: use io.read_text and run the regex on the file! - comments = self.get_ai_comment(str(path_abs)) + content = self.io.read_text(str(path_abs)) + if match := self.ai_comment_pattern.search(content): + if self.verbose: + dump(True) + return True if self.verbose: - dump(bool(comments)) - return bool(comments) + dump(False) + return False except Exception as err: if self.verbose: print("error")