diff --git a/aider/io.py b/aider/io.py index e98d9f359..5fdd1df6a 100644 --- a/aider/io.py +++ b/aider/io.py @@ -1,6 +1,5 @@ import base64 import os -import threading import time import webbrowser from collections import defaultdict @@ -26,7 +25,7 @@ from rich.style import Style as RichStyle from rich.text import Text from aider.mdstream import MarkdownStream -from aider.watch import watch_source_files +from aider.watch import FileWatcher from .dump import dump # noqa: F401 from .utils import is_image_file diff --git a/aider/watch.py b/aider/watch.py index 823a50369..4b0c19a61 100644 --- a/aider/watch.py +++ b/aider/watch.py @@ -1,6 +1,7 @@ import re +import threading from pathlib import Path -from typing import Optional, Set +from typing import Optional from pathspec import PathSpec from pathspec.patterns import GitWildMatchPattern @@ -195,14 +196,17 @@ def main(): def ignore_test_files(path): return "test" in path.name.lower() + watcher = FileWatcher(directory) try: - for changed_files in watch_source_files( - directory, args.gitignore, ignore_func=ignore_test_files - ): - for file in sorted(changed_files): - print(file) + watcher.start(gitignores=args.gitignore, ignore_func=ignore_test_files) + while True: + if changes := watcher.get_changes(): + for file in sorted(changes.keys()): + print(file) + watcher.changed_files = None except KeyboardInterrupt: print("\nStopped watching files") + watcher.stop() if __name__ == "__main__":