From d0afacd745d4a21dfa3e5b66fcdbdfec9ac98eaa Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Fri, 9 Aug 2024 16:24:21 -0300 Subject: [PATCH] feat: Add support for dropping read-only files in /drop command --- aider/commands.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/aider/commands.py b/aider/commands.py index de1ca23df..62da6b2a6 100644 --- a/aider/commands.py +++ b/aider/commands.py @@ -590,8 +590,10 @@ class Commands: def completions_drop(self): files = self.coder.get_inchat_relative_files() - files = [self.quote_fname(fn) for fn in files] - return files + read_only_files = [self.coder.get_rel_fname(fn) for fn in self.coder.abs_read_only_fnames] + all_files = files + read_only_files + all_files = [self.quote_fname(fn) for fn in all_files] + return all_files def cmd_drop(self, args=""): "Remove files from the chat session to free up context space" @@ -599,6 +601,8 @@ class Commands: if not args.strip(): self.io.tool_output("Dropping all files from the chat session.") self.coder.abs_fnames = set() + self.coder.abs_read_only_fnames = set() + return filenames = parse_quoted_filenames(args) for word in filenames: @@ -612,6 +616,9 @@ class Commands: if abs_fname in self.coder.abs_fnames: self.coder.abs_fnames.remove(abs_fname) self.io.tool_output(f"Removed {matched_file} from the chat") + elif abs_fname in self.coder.abs_read_only_fnames: + self.coder.abs_read_only_fnames.remove(abs_fname) + self.io.tool_output(f"Removed read-only file {matched_file} from the chat") def cmd_git(self, args): "Run a git command"