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)