mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-23 22:04:59 +00:00
aider: Added error message when no files matched in cmd_add and cmd_drop.
# Context: USER: in cmd_add and cmd_drop, print an error if no files matched ASSISTANT: To print an error message when no files are matched in `cmd_add` and `cmd_drop`, you can add a check for the length of `matched_files` and print an error message if it's zero. Here are the changes: ```python aider/coder.py <<<<<<< ORIGINAL def cmd_add(self, args): "Add matching files to the chat" files = self.get_active_files() for word in args.split(): matched_files = [file for file in files if word in file] ======= def cmd_add(self, args): "Add matching files to the chat" files = self.get_active_files() for word in args.split(): matched_files = [file for file in files if word in file] if not matched_files: self.console.print(f"[red]No files matched '{word}'") >>>>>>> UPDATED aider/coder.py <<<<<<< ORIGINAL def cmd_drop(self, args): "Remove matching files from the chat" for word in args.split(): matched_files = [file for file in self.fnames if word in os.path.relpath(file, self.root)] ======= def cmd_drop(self, args): "Remove matching files from the chat" for word in args.split(): matched_files = [file for file in self.fnames if word in os.path.relpath(file, self.root)] if not matched_files: self.console.print(f"[red]No files matched '{word}'") >>>>>>> UPDATED ```
This commit is contained in:
parent
ff23292f83
commit
921546881e
1 changed files with 4 additions and 0 deletions
|
@ -543,6 +543,8 @@ class Coder:
|
|||
files = self.get_active_files()
|
||||
for word in args.split():
|
||||
matched_files = [file for file in files if word in file]
|
||||
if not matched_files:
|
||||
self.console.print(f"[red]No files matched '{word}'")
|
||||
for matched_file in matched_files:
|
||||
abs_file_path = os.path.abspath(os.path.join(self.root, matched_file))
|
||||
if abs_file_path not in self.fnames:
|
||||
|
@ -556,6 +558,8 @@ class Coder:
|
|||
|
||||
for word in args.split():
|
||||
matched_files = [file for file in self.fnames if word in os.path.relpath(file, self.root)]
|
||||
if not matched_files:
|
||||
self.console.print(f"[red]No files matched '{word}'")
|
||||
for matched_file in matched_files:
|
||||
relative_fname = os.path.relpath(matched_file, self.root)
|
||||
self.fnames.remove(matched_file)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue