This commit is contained in:
Vladimir Krivosheev
2018-11-20 11:21:02 +01:00
parent 0b0ef505d3
commit 00dcb5ade5
@@ -11,13 +11,14 @@ import com.intellij.openapi.roots.libraries.LibraryUtil
import com.intellij.openapi.util.io.FileUtil
import com.intellij.openapi.vfs.LocalFileProvider
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.util.PathUtil
import com.intellij.util.PlatformUtils
fun displayUrlRelativeToProject(file: VirtualFile, url: String, project: Project, includeFilePath: Boolean, moduleOnTheLeft: Boolean): String {
fun displayUrlRelativeToProject(file: VirtualFile, url: String, project: Project, isIncludeFilePath: Boolean, moduleOnTheLeft: Boolean): String {
var result = url
if (includeFilePath) {
val projectHomeUrl = project.baseDir?.presentableUrl
if (isIncludeFilePath) {
val projectHomeUrl = PathUtil.toSystemDependentName(project.basePath)
result = when {
projectHomeUrl != null && result.startsWith(projectHomeUrl) -> "...${result.substring(projectHomeUrl.length)}"
else -> FileUtil.getLocationRelativeToUserHome(file.presentableUrl)
@@ -35,8 +36,10 @@ fun displayUrlRelativeToProject(file: VirtualFile, url: String, project: Project
}
}
if (PlatformUtils.isCidr() || PlatformUtils.isRider()) // see PredefinedSearchScopeProviderImpl.getPredefinedScopes for the other place to fix.
// see PredefinedSearchScopeProviderImpl.getPredefinedScopes for the other place to fix.
if (PlatformUtils.isCidr() || PlatformUtils.isRider()) {
return result
}
val module = ModuleUtilCore.findModuleForFile(file, project)
return when {
@@ -53,5 +56,5 @@ val Project.isExternalStorageEnabled: Boolean
}
val manager = ServiceManager.getService(this, ExternalStorageConfigurationManager::class.java) ?: return false
return manager.isEnabled() || (ApplicationManager.getApplication()?.isUnitTestMode ?: false)
return manager.isEnabled || (ApplicationManager.getApplication()?.isUnitTestMode ?: false)
}