Skip to content

Commit

Permalink
Fix over-including when view_project_root is set.
Browse files Browse the repository at this point in the history
https: //github.com//pull/6767 introduces a regression. While it fixes the bug with overlapping directories, it causes too many directories to now become included. This happens because the change avoids excluding files under any root directory, however the project root itself is a root directory when `view_project_root` is set. This results in nothing getting excluded, which defeats the purpose of view_project_root (it behaves the same as just adding `.` into directories).

The fix is to only avoid excluding files under any user-declared root directories.

Change-Id: I7f082b46dd036afc0ba8cfe596e574b021cf27fb
  • Loading branch information
jdai8 committed Nov 18, 2024
1 parent 353dac8 commit 233cd0e
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,13 @@ public ImportRoots build() {
}

private @NotNull List<WorkspacePath> selectExcludes(ImmutableCollection<WorkspacePath> rootDirectories) {
var userDeclaredRootDirectories = rootDirectories.stream().filter(rootDirectory -> !rootDirectory.isWorkspaceRoot()).collect(toImmutableSet());
Queue<File> files = new LinkedList<>(Collections.singletonList(workspaceRoot.directory()));
var result = new ArrayList<File>();
while (!files.isEmpty()) {
File file = files.poll();
if (rootDirectories.stream().anyMatch(d -> FileUtil.isAncestor(file, workspaceRoot.fileForPath(d), /*strict=*/ true)) &&
rootDirectories.stream().noneMatch(d -> FileUtil.filesEqual(file, workspaceRoot.fileForPath(d)))
userDeclaredRootDirectories.stream().noneMatch(d -> FileUtil.filesEqual(file, workspaceRoot.fileForPath(d)))
) {
var children = file.listFiles(File::isDirectory);
if (children != null) {
Expand Down

0 comments on commit 233cd0e

Please sign in to comment.