diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ModuleDefaultVcsRootPolicy.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ModuleDefaultVcsRootPolicy.java index b00fc6958a2c..a2f510532f03 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ModuleDefaultVcsRootPolicy.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ModuleDefaultVcsRootPolicy.java @@ -116,18 +116,27 @@ public class ModuleDefaultVcsRootPolicy extends DefaultVcsRootPolicy { public VirtualFile getVcsRootFor(@NotNull VirtualFile file) { FileIndexFacade indexFacade = PeriodicalTasksCloser.getInstance().safeGetService(myProject, FileIndexFacade.class); if (myBaseDir != null && indexFacade.isValidAncestor(myBaseDir, file)) { + LOG.debug("File " + file + " is under project base dir " + myBaseDir); return myBaseDir; } VirtualFile contentRoot = ProjectRootManager.getInstance(myProject).getFileIndex().getContentRootForFile(file, Registry.is("ide.hide.excluded.files")); - if (contentRoot != null && contentRoot.isDirectory()) { - return contentRoot; + if (contentRoot != null) { + LOG.debug("Content root for file " + file + " is " + contentRoot); + if (contentRoot.isDirectory()) { + return contentRoot; + } + VirtualFile parent = contentRoot.getParent(); + LOG.debug("Content root is not a directory, using its parent " + parent); + return parent; } if (ProjectKt.isDirectoryBased(myProject)) { VirtualFile ideaDir = ProjectKt.getStateStore(myProject).getDirectoryStoreFile(); if (ideaDir != null && VfsUtilCore.isAncestor(ideaDir, file, false)) { + LOG.debug("File " + file + " is under .idea"); return ideaDir; } } + LOG.debug("Couldn't find proper root for " + file); return null; }