From e001b7fb46d07939c3ea72a70eb6ca8bda6ec72a Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Sun, 1 Dec 2024 15:25:46 -0800 Subject: [PATCH] fix: improve AI comment regex pattern to match end of line --- aider/watch.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/aider/watch.py b/aider/watch.py index c17d3e0c3..0a0e74290 100644 --- a/aider/watch.py +++ b/aider/watch.py @@ -66,7 +66,7 @@ class FileWatcher: """Watches source files for changes and AI comments""" # Compiled regex pattern for AI comments - ai_comment_pattern = re.compile(r"(?:#|//) *(ai\b.*|ai|.*\bai!?)", re.IGNORECASE) + ai_comment_pattern = re.compile(r"(?:#|//) *(ai\b.*|ai\b.*|.*\bai!?)$", re.IGNORECASE) def __init__(self, coder, gitignores=None, verbose=False): @@ -108,6 +108,7 @@ class FileWatcher: # Check if file contains AI markers try: + # TODO: use get_ai_comments() for this with open(str(path_abs), "r", encoding=self.io.encoding) as f: content = f.read() match = self.ai_comment_pattern.search(content)