mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-30 01:04:59 +00:00
refactor: move file change processing logic from io.py to watch.py
This commit is contained in:
parent
2e5981ecb3
commit
0890b32425
2 changed files with 19 additions and 18 deletions
19
aider/io.py
19
aider/io.py
|
@ -379,24 +379,7 @@ class InputOutput:
|
||||||
self.changed_files = changed
|
self.changed_files = changed
|
||||||
|
|
||||||
#ai move all this ...
|
#ai move all this ...
|
||||||
dump(changed)
|
self.changed_files = process_file_changes(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.interrupt_input()
|
self.interrupt_input()
|
||||||
break
|
break
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
|
@ -135,6 +135,24 @@ def watch_source_files(
|
||||||
result[file] = comments
|
result[file] = comments
|
||||||
yield result
|
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"):
|
def get_ai_comment(filepath, encoding="utf-8"):
|
||||||
"""Extract all AI comments from a file"""
|
"""Extract all AI comments from a file"""
|
||||||
comments = []
|
comments = []
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue