mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-29 08:44:59 +00:00
fix: handle absolute paths and globs in cmd_read_only
This commit is contained in:
parent
5d3a60228c
commit
f70a82791b
1 changed files with 13 additions and 5 deletions
|
@ -1170,12 +1170,20 @@ class Commands:
|
||||||
# First collect all expanded paths
|
# First collect all expanded paths
|
||||||
for pattern in filenames:
|
for pattern in filenames:
|
||||||
expanded_pattern = expanduser(pattern)
|
expanded_pattern = expanduser(pattern)
|
||||||
expanded_paths = Path(self.coder.root).rglob(expanded_pattern)
|
if os.path.isabs(expanded_pattern):
|
||||||
|
# For absolute paths, check if file exists directly
|
||||||
if not expanded_paths:
|
path = Path(expanded_pattern)
|
||||||
self.io.tool_error(f"No matches found for: {pattern}")
|
if path.exists():
|
||||||
|
all_paths.append(path)
|
||||||
|
else:
|
||||||
|
self.io.tool_error(f"No matches found for: {pattern}")
|
||||||
else:
|
else:
|
||||||
all_paths.extend(expanded_paths)
|
# For relative paths and globs, use glob from the root directory
|
||||||
|
matches = list(Path(self.coder.root).glob("**/" + expanded_pattern))
|
||||||
|
if not matches:
|
||||||
|
self.io.tool_error(f"No matches found for: {pattern}")
|
||||||
|
else:
|
||||||
|
all_paths.extend(matches)
|
||||||
|
|
||||||
# Then process them in sorted order
|
# Then process them in sorted order
|
||||||
for path in sorted(all_paths):
|
for path in sorted(all_paths):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue