refactor: improve file change handling in input loop

This commit is contained in:
Paul Gauthier 2024-10-25 13:17:53 -07:00 committed by Paul Gauthier (aider)
parent 7587d76fd1
commit 1261a335f4

View file

@ -373,9 +373,8 @@ class InputOutput:
for changed in watch_source_files(
root, stop_event=stop_event, gitignores=gitignore
):
dump(changed)
if changed:
self.changed_files = list(changed)[0] # Take the first changed file
self.changed_files = list(changed)
self.interrupt_input()
break
except Exception as e:
@ -384,7 +383,6 @@ class InputOutput:
# Start the watcher thread
watcher = threading.Thread(target=watch_files, daemon=True)
watcher.start()
dump(watcher)
rel_fnames = list(rel_fnames)
show = ""
@ -441,11 +439,13 @@ class InputOutput:
)
else:
line = input(show)
dump(line)#
# Check if we were interrupted by a file change
if self.changed_files:
changed = self.changed_files
changed = ' '.join(self.changed_files)
self.changed_files = None
dump(changed)
return f"/add {changed}" # Return an edit command for the changed file
except EOFError:
return ""