From c26d7d23b57eb4302281a4e98babcb798accf8be Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Fri, 25 Oct 2024 16:23:44 -0700 Subject: [PATCH] fix: improve regex pattern for AI comment detection --- aider/watch.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/aider/watch.py b/aider/watch.py index 4dea3ada0..733d0675e 100644 --- a/aider/watch.py +++ b/aider/watch.py @@ -8,6 +8,7 @@ from watchfiles import watch from aider.dump import dump # noqa +#ai turn off verbose! VERBOSE = True @@ -144,9 +145,9 @@ def get_ai_comment(filepath, encoding="utf-8"): comments = [] try: with open(filepath, encoding=encoding, errors="ignore") as f: - for line in f: # ai - if match := re.search(r"(?:#|//) *ai(\b.*)?", line, re.IGNORECASE): - comment = match.group(1).strip() + for line in f: + if match := re.search(r"(?:#|//) *(ai\b.*|ai)", line, re.IGNORECASE): + comment = match.group(0).strip() if comment: comments.append(comment) except (IOError, UnicodeDecodeError):