From 0890b32425d8d02a1415f60e48fac5ef3b1aa362 Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Fri, 25 Oct 2024 16:10:49 -0700 Subject: [PATCH] refactor: move file change processing logic from io.py to watch.py --- aider/io.py | 19 +------------------ aider/watch.py | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/aider/io.py b/aider/io.py index 48d812d68..26c4d091a 100644 --- a/aider/io.py +++ b/aider/io.py @@ -379,24 +379,7 @@ class InputOutput: self.changed_files = changed #ai move all this ... - dump(changed) - # Check if any values contain ! - if any( - "!" in comment - for comments in changed.values() - if comments - for comment in comments - ): - self.changed_files = [ - "\n".join( - comment - for comments in changed.values() - if comments - for comment in comments - ) - ] - else: - self.changed_files = list(changed.keys()) + self.changed_files = process_file_changes(changed) self.interrupt_input() break except Exception as e: diff --git a/aider/watch.py b/aider/watch.py index 3a0830ebe..5e623337e 100644 --- a/aider/watch.py +++ b/aider/watch.py @@ -135,6 +135,24 @@ def watch_source_files( result[file] = comments yield result +def process_file_changes(changed): + """Process file changes and handle special ! comments""" + if any( + "!" in comment + for comments in changed.values() + if comments + for comment in comments + ): + return [ + "\n".join( + comment + for comments in changed.values() + if comments + for comment in comments + ) + ] + return list(changed.keys()) + def get_ai_comment(filepath, encoding="utf-8"): """Extract all AI comments from a file""" comments = []