From bbd56d44e8b35a396baf8a6ffff04f545653fabc Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Fri, 23 Aug 2024 06:41:28 -0700 Subject: [PATCH] fix: Handle tilde paths in cmd_drop for read-only files --- aider/commands.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/aider/commands.py b/aider/commands.py index 714502023..4d06cbf35 100644 --- a/aider/commands.py +++ b/aider/commands.py @@ -649,18 +649,21 @@ class Commands: filenames = parse_quoted_filenames(args) for word in filenames: + # Expand tilde in the path + expanded_word = os.path.expanduser(word) + # Handle read-only files separately, without glob_filtered_to_repo - read_only_matched = [f for f in self.coder.abs_read_only_fnames if word in f] + read_only_matched = [f for f in self.coder.abs_read_only_fnames if expanded_word in f] if read_only_matched: for matched_file in read_only_matched: self.coder.abs_read_only_fnames.remove(matched_file) self.io.tool_output(f"Removed read-only file {matched_file} from the chat") - matched_files = self.glob_filtered_to_repo(word) + matched_files = self.glob_filtered_to_repo(expanded_word) if not matched_files: - matched_files.append(word) + matched_files.append(expanded_word) for matched_file in matched_files: abs_fname = self.coder.abs_root_path(matched_file)