do not add owner if it is only one parent

This commit is contained in:
Sergey Malenkov
2017-12-29 15:29:11 +03:00
parent 36258bd6a0
commit e2a491e37c
@@ -175,8 +175,9 @@ public class ProjectViewDirectoryHelper {
@NotNull
private static JBIterable<PsiDirectory> getParents(PsiDirectory directory, Object owner) {
if (directory != null) directory = directory.getParent(); // because JBIterable adds first parent without comparing with owner
return directory != null && owner instanceof PsiDirectory && PsiTreeUtil.isAncestor((PsiDirectory)owner, directory, true)
? JBIterable.generate(directory.getParent(), PsiDirectory::getParent).takeWhile(dir -> dir != null && !dir.equals(owner))
? JBIterable.generate(directory, PsiDirectory::getParent).takeWhile(dir -> dir != null && !dir.equals(owner))
: JBIterable.empty();
}