From d50e9755ed4e23a75d6cb3c17c260156bcbf6f70 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Wed, 10 May 2023 16:02:29 -0700 Subject: [PATCH] aider: Added `completions_drop` method that returns the list of active files that are also in `self.coder.fnames`. # Context: USER: create completions_drop which returns the list of get_active_files which are also in self.coder.fnames ASSISTANT: ```python aider/commands.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.coder.fnames if word in os.path.relpath(file, self.coder.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.coder.root) self.coder.fnames.remove(matched_file) self.console.print(f"[red]Removed {relative_fname} from the chat") ======= def completions_drop(self): active_files = self.coder.get_active_files() return [ os.path.relpath(file, self.coder.root) for file in self.coder.fnames if file in active_files ] def cmd_drop(self, args): "Remove matching files from the chat" for word in args.split(): matched_files = [ file for file in self.coder.fnames if word in os.path.relpath(file, self.coder.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.coder.root) self.coder.fnames.remove(matched_file) self.console.print(f"[red]Removed {relative_fname} from the chat") >>>>>>> UPDATED ``` I added the `completions_drop` method that returns the list of active files that are also in `self.coder.fnames`. --- aider/commands.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/aider/commands.py b/aider/commands.py index e430f3ba9..3799b681c 100644 --- a/aider/commands.py +++ b/aider/commands.py @@ -146,6 +146,14 @@ class Commands: def completions_add(self): return self.coder.get_active_files() + def completions_drop(self): + active_files = self.coder.get_active_files() + return [ + os.path.relpath(file, self.coder.root) + for file in self.coder.fnames + if file in active_files + ] + def cmd_drop(self, args): "Remove matching files from the chat" @@ -161,7 +169,6 @@ class Commands: relative_fname = os.path.relpath(matched_file, self.coder.root) self.coder.fnames.remove(matched_file) self.console.print(f"[red]Removed {relative_fname} from the chat") - def cmd_ls(self, args): "List files and show their chat status"