fix: Improve run_interactive_subprocess method in EditBlockCoder

This commit is contained in:
Paul Gauthier 2024-08-21 15:20:31 -07:00 committed by Paul Gauthier (aider)
parent a2cb660183
commit 377da1537d

View file

@ -29,14 +29,13 @@ class EditBlockCoder(Coder):
return edits return edits
def run_interactive_subprocess(self, command): def run_interactive_subprocess(self, command):
dump(repr(command)) return subprocess.run(
if os.name == "posix": # Unix-like systems (Linux, macOS) command,
return subprocess.run(command, shell=True) text=True,
# return pty.spawn(command) shell=True,
elif os.name == "nt": # Windows encoding=self.io.encoding,
return subprocess.run(command, shell=True) errors="replace",
else: )
raise OSError("Unsupported operating system")
def handle_shell_commands(self, commands_str): def handle_shell_commands(self, commands_str):
commands = commands_str.strip().splitlines() commands = commands_str.strip().splitlines()
@ -61,9 +60,7 @@ class EditBlockCoder(Coder):
failed = [] failed = []
passed = [] passed = []
dump(edits)
for edit in edits: for edit in edits:
dump(edit)
if edit[0] is None: if edit[0] is None:
self.handle_shell_commands(edit[1]) self.handle_shell_commands(edit[1])
continue continue
@ -86,8 +83,6 @@ class EditBlockCoder(Coder):
else: else:
failed.append(edit) failed.append(edit)
dump(failed)
dump(passed)
if not failed: if not failed:
return return