mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
space: highlight current line when calling "Open on Space" from the editor
GitOrigin-RevId: 911dcacf85c2ac47b3c66f283b6a0487e68b3c06
This commit is contained in:
committed by
intellij-monorepo-bot
parent
c89f3a7751
commit
71198d562e
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2020 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.
|
||||
// Copyright 2000-2021 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 com.intellij.space.utils
|
||||
|
||||
import circlet.client.api.*
|
||||
@@ -28,8 +28,8 @@ object SpaceUrls {
|
||||
|
||||
fun issues(key: ProjectKey): String = p(key).issues().toUrl()
|
||||
|
||||
fun fileAnnotate(key: ProjectKey, repo: String, hash: String, relativePath: String): String =
|
||||
p(key).fileAnnotate(repo, hash, relativePath).toUrl()
|
||||
fun fileAnnotate(key: ProjectKey, repo: String, hash: String, relativePath: String, selectedLine: Int? = null): String =
|
||||
p(key).fileAnnotate(repo, hash, relativePath, selectedLine).toUrl()
|
||||
|
||||
// member
|
||||
fun member(profile: TD_MemberProfile): String = member(profile.username)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2020 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.
|
||||
// Copyright 2000-2021 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 com.intellij.space.vcs
|
||||
|
||||
import circlet.client.api.ProjectKey
|
||||
@@ -145,8 +145,12 @@ class SpaceVcsOpenInBrowserActionGroup :
|
||||
|
||||
val repoDescription = findProjectInfo(gitRepository, project) ?: return null
|
||||
|
||||
return repoDescription.projectInfos.map { OpenData.File(project, it, repoDescription.name, virtualFile, gitRepository) }
|
||||
val editor = dataContext.getData(CommonDataKeys.EDITOR)
|
||||
val line = if (editor != null && editor.document.lineCount >= 1) {
|
||||
editor.caretModel.currentCaret.logicalPosition.line
|
||||
} else null
|
||||
|
||||
return repoDescription.projectInfos.map { OpenData.File(project, it, repoDescription.name, virtualFile, line, gitRepository) }
|
||||
}
|
||||
|
||||
private fun getDataFromHistory(dataContext: DataContext, project: Project): List<OpenData>? {
|
||||
@@ -221,13 +225,15 @@ class SpaceVcsOpenInBrowserActionGroup :
|
||||
class File(project: Project,
|
||||
projectKey: SpaceProjectInfo,
|
||||
repo: String,
|
||||
private val virtualFile: VirtualFile, private val gitRepository: GitRepository) : OpenData(project, projectKey, repo) {
|
||||
private val virtualFile: VirtualFile,
|
||||
private val selectedLine: Int? = null,
|
||||
private val gitRepository: GitRepository) : OpenData(project, projectKey, repo) {
|
||||
override val url: String?
|
||||
get() {
|
||||
val relativePath = VfsUtilCore.getRelativePath(virtualFile, gitRepository.root) ?: return null
|
||||
val hash = getCurrentFileRevisionHash(project, virtualFile) ?: return null
|
||||
|
||||
return SpaceUrls.fileAnnotate(info.key, repo, hash, relativePath)
|
||||
return SpaceUrls.fileAnnotate(info.key, repo, hash, relativePath, selectedLine)
|
||||
}
|
||||
|
||||
private fun getCurrentFileRevisionHash(project: Project, file: VirtualFile): String? {
|
||||
|
||||
Reference in New Issue
Block a user