From 9a00f4c1753bea982d04e8cdb55e9a20e51dd00d Mon Sep 17 00:00:00 2001 From: Jack Dai Date: Wed, 18 Sep 2024 00:29:37 -0700 Subject: [PATCH] Fix view_project_root with overlapping directories When `view_project_root: true` and there are overlapping directories, for example: The repo contains these directories: - foo - foo/bar - foo/baz And .bazelproject is: ``` view_project_root: true directories: foo foo/bar ``` Then, `foo/baz` will incorrectly be excluded. This is unexpected because it's contained under the `foo` directory. This commit fixes the behavior, so that files are not excluded if they are under any root directory. Change-Id: Icd218fa33a79a7c74986255cce7788ea6b4d586d --- .../google/idea/blaze/base/sync/projectview/ImportRoots.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/base/src/com/google/idea/blaze/base/sync/projectview/ImportRoots.java b/base/src/com/google/idea/blaze/base/sync/projectview/ImportRoots.java index 24981a10c7d..c8fdef5e933 100644 --- a/base/src/com/google/idea/blaze/base/sync/projectview/ImportRoots.java +++ b/base/src/com/google/idea/blaze/base/sync/projectview/ImportRoots.java @@ -183,7 +183,9 @@ public ImportRoots build() { var result = new ArrayList(); while (!files.isEmpty()) { File file = files.poll(); - if (rootDirectories.stream().anyMatch(d -> FileUtil.isAncestor(file, workspaceRoot.fileForPath(d), /*strict=*/ true))) { + if (rootDirectories.stream().anyMatch(d -> FileUtil.isAncestor(file, workspaceRoot.fileForPath(d), /*strict=*/ true)) && + rootDirectories.stream().noneMatch(d -> FileUtil.filesEqual(file, workspaceRoot.fileForPath(d))) + ) { var children = file.listFiles(File::isDirectory); if (children != null) { files.addAll(List.of(children));