From 881527ddd045bc75935022e8fb9a9073a8f8fb8c Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Fri, 6 Dec 2024 12:23:27 -0800 Subject: [PATCH] handle and test for trailing whitespace after ai --- aider/watch.py | 2 +- tests/basic/test_watch.py | 2 +- tests/fixtures/watch.js | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/aider/watch.py b/aider/watch.py index bace1fd14..103309505 100644 --- a/aider/watch.py +++ b/aider/watch.py @@ -72,7 +72,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\b.*|.*\bai!?)$", re.IGNORECASE) + ai_comment_pattern = re.compile(r"(?:#|//|--) *(ai\b.*|ai\b.*|.*\bai!?) *$", re.IGNORECASE) def __init__(self, coder, gitignores=None, verbose=False): self.coder = coder diff --git a/tests/basic/test_watch.py b/tests/basic/test_watch.py index d8bce3d6f..1c5d4e6e3 100644 --- a/tests/basic/test_watch.py +++ b/tests/basic/test_watch.py @@ -37,7 +37,7 @@ def test_ai_comment_pattern(): # Test JavaScript fixture js_path = fixtures_dir / "watch.js" js_lines, js_comments, js_has_bang = watcher.get_ai_comments(str(js_path)) - js_expected = 14 + js_expected = 16 assert ( len(js_lines) == js_expected ), f"Expected {js_expected} AI comments in JavaScript fixture, found {len(js_lines)}" diff --git a/tests/fixtures/watch.js b/tests/fixtures/watch.js index ea7f4314d..e0d34604c 100644 --- a/tests/fixtures/watch.js +++ b/tests/fixtures/watch.js @@ -33,3 +33,6 @@ class Example { return 1; } } +// trailing whitespace ai +// trailing whitespace ai! +// 15-16