diff --git a/src/serena/agent.py b/src/serena/agent.py index d52215ca..3096a7da 100644 --- a/src/serena/agent.py +++ b/src/serena/agent.py @@ -597,15 +597,16 @@ class ListDirTool(Tool): :return: a JSON object with the names of directories and files within the given directory """ - def is_ignored_dir(abs_path: str): + def is_ignored_path(abs_path: str): rel_path = os.path.relpath(abs_path, self.project_root) - return self.language_server.is_ignored_path(rel_path) + return self.language_server.is_ignored_path(rel_path, ignore_unsupported_files=False) dirs, files = scan_directory( os.path.join(self.project_root, relative_path), relative_to=self.project_root, recursive=recursive, - is_ignored_dir=is_ignored_dir, + is_ignored_dir=is_ignored_path, + is_ignored_file=is_ignored_path, ) result = json.dumps({"dirs": dirs, "files": files}) diff --git a/src/serena/util/file_system.py b/src/serena/util/file_system.py index bd29e961..8d7ed90f 100644 --- a/src/serena/util/file_system.py +++ b/src/serena/util/file_system.py @@ -7,12 +7,14 @@ def scan_directory( recursive: bool = False, relative_to: str | None = None, is_ignored_dir: Callable[[str], bool] = lambda x: False, + is_ignored_file: Callable[[str], bool] = lambda x: False, ) -> tuple[list[str], list[str]]: """ :param path: the path to scan :param recursive: whether to recursively scan subdirectories :param relative_to: the path to which the results should be relative to; if None, provide absolute paths :param is_ignored_dir: a function with which to determine whether the given directory (abs. path) shall be ignored + :param is_ignored_file: a function with which to determine whether the given file (abs. path) shall be ignored :return: the list of directories and files """ files = [] @@ -31,7 +33,8 @@ def scan_directory( result_path = entry_path if entry.is_file(): - files.append(result_path) + if not is_ignored_file(entry_path): + files.append(result_path) elif entry.is_dir(): if not is_ignored_dir(entry_path): directories.append(result_path)