feat: Add shell command to input history before execution

This commit is contained in:
Paul Gauthier (aider) 2024-08-21 05:17:18 -07:00
parent 623e4bb2d9
commit 4537e1a9f5
2 changed files with 5 additions and 0 deletions

View file

@ -50,6 +50,8 @@ class EditBlockCoder(Coder):
self.io.tool_output(f"{edit.strip()}", bold=True)
if self.io.confirm_ask("Do you want to run this suggested shell command?"):
try:
# Add the command to input history
self.io.add_to_input_history(f"/run {edit.strip()}")
self.run_interactive_subprocess(edit.split())
except Exception as e:
self.io.tool_error(str(e))

View file

@ -311,6 +311,9 @@ class InputOutput:
if not self.input_history_file:
return
FileHistory(self.input_history_file).append_string(inp)
# Also add to the in-memory history if it exists
if hasattr(self, 'session') and hasattr(self.session, 'history'):
self.session.history.append_string(inp)
def get_input_history(self):
if not self.input_history_file: