fix: Handle tilde paths in cmd_drop for read-only files

This commit is contained in:
Paul Gauthier (aider) 2024-08-23 06:41:28 -07:00
parent 00e4fdbb48
commit bbd56d44e8

View file

@ -649,18 +649,21 @@ class Commands:
filenames = parse_quoted_filenames(args) filenames = parse_quoted_filenames(args)
for word in filenames: 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 # 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: if read_only_matched:
for matched_file in read_only_matched: for matched_file in read_only_matched:
self.coder.abs_read_only_fnames.remove(matched_file) self.coder.abs_read_only_fnames.remove(matched_file)
self.io.tool_output(f"Removed read-only file {matched_file} from the chat") 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: if not matched_files:
matched_files.append(word) matched_files.append(expanded_word)
for matched_file in matched_files: for matched_file in matched_files:
abs_fname = self.coder.abs_root_path(matched_file) abs_fname = self.coder.abs_root_path(matched_file)