From f70a82791b0f1c221aaae656d21b43d08aae3da1 Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Fri, 25 Oct 2024 07:43:31 -0700 Subject: [PATCH] fix: handle absolute paths and globs in cmd_read_only --- aider/commands.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/aider/commands.py b/aider/commands.py index 01374dbe1..4644a3b57 100644 --- a/aider/commands.py +++ b/aider/commands.py @@ -1170,12 +1170,20 @@ class Commands: # First collect all expanded paths for pattern in filenames: expanded_pattern = expanduser(pattern) - expanded_paths = Path(self.coder.root).rglob(expanded_pattern) - - if not expanded_paths: - self.io.tool_error(f"No matches found for: {pattern}") + if os.path.isabs(expanded_pattern): + # For absolute paths, check if file exists directly + path = Path(expanded_pattern) + if path.exists(): + all_paths.append(path) + else: + self.io.tool_error(f"No matches found for: {pattern}") 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 for path in sorted(all_paths):