fix: Add ConfirmGroup to confirm file and shell command additions

This commit is contained in:
Paul Gauthier 2024-08-23 16:54:03 -07:00 committed by Paul Gauthier (aider)
parent b26550d93f
commit 668ab7e204

View file

@ -1252,7 +1252,8 @@ class Coder:
return return
add_files = "\n".join(mentioned_rel_fnames) + "\n" add_files = "\n".join(mentioned_rel_fnames) + "\n"
if not self.io.confirm_ask("Add these files to the chat?", subject=add_files): group = ConfirmGroup(mentioned_rel_fnames)
if not self.io.confirm_ask("Add these files to the chat?", subject=add_files, group=group):
return return
for rel_fname in mentioned_rel_fnames: for rel_fname in mentioned_rel_fnames:
@ -1811,19 +1812,22 @@ class Coder:
def run_shell_commands(self): def run_shell_commands(self):
done = set() done = set()
group = ConfirmGroup(set(self.shell_commands))
for command in self.shell_commands: for command in self.shell_commands:
if command in done: if command in done:
continue continue
done.add(command) done.add(command)
self.handle_shell_commands(command) self.handle_shell_commands(command, group)
def handle_shell_commands(self, commands_str): def handle_shell_commands(self, commands_str, group):
commands = commands_str.strip().splitlines() commands = commands_str.strip().splitlines()
command_count = sum( command_count = sum(
1 for cmd in commands if cmd.strip() and not cmd.strip().startswith("#") 1 for cmd in commands if cmd.strip() and not cmd.strip().startswith("#")
) )
prompt = "Run shell command?" if command_count == 1 else "Run shell commands?" prompt = "Run shell command?" if command_count == 1 else "Run shell commands?"
if not self.io.confirm_ask(prompt, subject="\n".join(commands), explicit_yes_required=True): if not self.io.confirm_ask(
prompt, subject="\n".join(commands), explicit_yes_required=True, group=group
):
return return
for command in commands: for command in commands: