UX-600 IDEA-223834 copy paths popups: add path from repository root provider

GitOrigin-RevId: f111d1536d5b57386502875b7e874f79b62437e0
This commit is contained in:
Dmitry.Krasilschikov
2019-11-07 02:40:58 +00:00
committed by intellij-monorepo-bot
parent a3e464b628
commit 5aeec4d113
2 changed files with 25 additions and 0 deletions
@@ -185,6 +185,11 @@
<action id="git4idea.commands.TestGitHttpLoginDialogAction" class="git4idea.commands.TestGitHttpLoginDialogAction"
text="Test Git Login Dialog" internal="true"/>
<action id="CopyPathFromRepositoryRootProvider" class="git4idea.actions.CopyPathFromRepositoryRootProvider"
text="Path From Repository Root">
<add-to-group group-id="CopyFileReference"/>
</action>
</actions>
<extensions defaultExtensionNs="com.intellij">
@@ -0,0 +1,20 @@
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package git4idea.actions
import com.intellij.ide.actions.CopyPathProvider
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.project.Project
import com.intellij.openapi.vfs.VfsUtilCore
import com.intellij.openapi.vfs.VirtualFile
import git4idea.repo.GitRepositoryManager
class CopyPathFromRepositoryRootProvider : CopyPathProvider() {
override fun getPathToElement(project: Project, virtualFile: VirtualFile?, editor: Editor?): String? {
if (virtualFile == null) return null
val repository = GitRepositoryManager.getInstance(project).getRepositoryForFile(virtualFile)
if (repository == null) return null
return VfsUtilCore.getRelativePath(virtualFile, repository.root)
}
}