mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-02 18:54:59 +00:00
fix: update regex pattern for AI comment detection
This commit is contained in:
parent
0960663811
commit
05daab24a2
1 changed files with 2 additions and 2 deletions
|
@ -135,13 +135,13 @@ def watch_source_files(
|
||||||
result[file] = comment
|
result[file] = comment
|
||||||
yield result
|
yield result
|
||||||
|
|
||||||
|
#ai return a list of all the ai comments in each file
|
||||||
def get_ai_comment(filepath, encoding="utf-8"):
|
def get_ai_comment(filepath, encoding="utf-8"):
|
||||||
"""Extract AI comment from a file if present"""
|
"""Extract AI comment from a file if present"""
|
||||||
try:
|
try:
|
||||||
with open(filepath, encoding=encoding, errors="ignore") as f:
|
with open(filepath, encoding=encoding, errors="ignore") as f:
|
||||||
for line in f:
|
for line in f:
|
||||||
if match := re.search(r"(?:#|//) *ai:? *(.*)", line, re.IGNORECASE):
|
if match := re.search(r"(?:#|//) *ai\b(.*)", line, re.IGNORECASE):
|
||||||
return match.group(1).strip()
|
return match.group(1).strip()
|
||||||
except (IOError, UnicodeDecodeError):
|
except (IOError, UnicodeDecodeError):
|
||||||
return None
|
return None
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue