mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-28 08:14:59 +00:00
feat: make /drop use substring matching for non-glob patterns
This commit is contained in:
parent
d54fbd6592
commit
ba17dceb4d
1 changed files with 14 additions and 7 deletions
|
@ -808,15 +808,22 @@ class Commands:
|
|||
# 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 with substring matching
|
||||
read_only_matched = [f for f in self.coder.abs_read_only_fnames if expanded_word in f]
|
||||
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")
|
||||
|
||||
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(expanded_word)
|
||||
# For editable files, use glob if word contains glob chars, otherwise use substring
|
||||
if any(c in expanded_word for c in "*?[]"):
|
||||
matched_files = self.glob_filtered_to_repo(expanded_word)
|
||||
else:
|
||||
# Use substring matching like we do for read-only files
|
||||
matched_files = [
|
||||
self.coder.get_rel_fname(f)
|
||||
for f in self.coder.abs_fnames
|
||||
if expanded_word in f
|
||||
]
|
||||
|
||||
if not matched_files:
|
||||
matched_files.append(expanded_word)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue