refactor: update regex to only match ai comments at end of line

This commit is contained in:
Paul Gauthier (aider) 2024-12-01 09:50:50 -08:00
parent ddbe2853ea
commit 2cc671df75

View file

@ -66,8 +66,7 @@ class FileWatcher:
"""Watches source files for changes and AI comments""" """Watches source files for changes and AI comments"""
# Compiled regex pattern for AI comments # Compiled regex pattern for AI comments
# make this pattern match at the end of a line ai! ai_comment_pattern = re.compile(r"(?:#|//) *.*\bai!? *$", re.IGNORECASE)
ai_comment_pattern = re.compile(r"(?:#|//) *(ai\b.*|ai|.*\bai!)", re.IGNORECASE)
def __init__(self, coder, gitignores=None, verbose=False): def __init__(self, coder, gitignores=None, verbose=False):
self.coder = coder self.coder = coder