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`.
This commit is contained in:
Paul Gauthier 2023-05-10 16:02:29 -07:00
parent bc43d9ac31
commit d50e9755ed

View file

@ -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"