mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[lvcs] improve presentation for the unnamed changes
GitOrigin-RevId: 297e9b30f7f5fdc85d24b0723d9fda0234a94941
This commit is contained in:
committed by
intellij-monorepo-bot
parent
ac7bfab011
commit
4e9b0f7557
@@ -4,6 +4,7 @@ package com.intellij.platform.lvcs.impl
|
||||
import com.intellij.history.core.Paths
|
||||
import com.intellij.history.core.changes.ChangeSet
|
||||
import com.intellij.history.integration.LocalHistoryBundle
|
||||
import com.intellij.openapi.util.NlsContexts
|
||||
import com.intellij.openapi.util.NlsSafe
|
||||
|
||||
abstract class ChangeSetActivityItem(changeSet: ChangeSet) : ActivityItem {
|
||||
@@ -20,16 +21,22 @@ abstract class ChangeSetActivityItem(changeSet: ChangeSet) : ActivityItem {
|
||||
override fun hashCode(): Int = id.hashCode()
|
||||
}
|
||||
|
||||
internal class ChangeActivityItem(changeSet: ChangeSet) : ChangeSetActivityItem(changeSet) {
|
||||
override val name = changeSet.name ?: changeSet.presentableNameFromPaths()
|
||||
internal class ChangeActivityItem(changeSet: ChangeSet, scope: ActivityScope) : ChangeSetActivityItem(changeSet) {
|
||||
override val name = getName(changeSet, scope)
|
||||
|
||||
private fun getName(changeSet: ChangeSet, scope: ActivityScope): @NlsContexts.Label String? {
|
||||
if (changeSet.name != null) return changeSet.name
|
||||
if (scope is ActivityScope.SingleFile || scope is ActivityScope.Selection) return LocalHistoryBundle.message("activity.item.presentation")
|
||||
return changeSet.presentableNameFromPaths()
|
||||
}
|
||||
}
|
||||
|
||||
private fun ChangeSet.presentableNameFromPaths(): String? {
|
||||
private fun ChangeSet.presentableNameFromPaths(): @NlsContexts.Label String? {
|
||||
val allPaths = affectedPaths
|
||||
if (allPaths.isEmpty()) return null
|
||||
|
||||
val firstPathName = Paths.getNameOf(allPaths.first())
|
||||
if (allPaths.size == 1) return firstPathName
|
||||
if (allPaths.size == 1) return LocalHistoryBundle.message("activity.item.presentation.from.path", firstPathName)
|
||||
return LocalHistoryBundle.message("activity.item.presentation.from.paths", firstPathName, allPaths.size - 1)
|
||||
}
|
||||
|
||||
@@ -38,7 +45,7 @@ internal class LabelActivityItem(changeSet: ChangeSet) : ChangeSetActivityItem(c
|
||||
val color = changeSet.labelColor
|
||||
}
|
||||
|
||||
fun ChangeSet.toActivityItem(): ActivityItem {
|
||||
fun ChangeSet.toActivityItem(scope: ActivityScope): ActivityItem {
|
||||
if (isLabelOnly) return LabelActivityItem(this)
|
||||
return ChangeActivityItem(this)
|
||||
return ChangeActivityItem(this, scope)
|
||||
}
|
||||
+2
-2
@@ -27,12 +27,12 @@ internal class LocalHistoryActivityProvider(val project: Project, private val ga
|
||||
if (scope is ActivityScope.File) {
|
||||
val path = gateway.getPathOrUrl(scope.file)
|
||||
gateway.registerUnsavedDocuments(facade)
|
||||
facade.collectChanges(projectId, path, scopeFilter) { changeSet -> result.add(changeSet.toActivityItem()) }
|
||||
facade.collectChanges(projectId, path, scopeFilter) { changeSet -> result.add(changeSet.toActivityItem(scope)) }
|
||||
}
|
||||
else {
|
||||
for (changeSet in facade.changes) {
|
||||
if (changeSet.isLabelOnly && !changeSet.changes.any { it.affectsProject(projectId) }) continue
|
||||
result.add(changeSet.toActivityItem())
|
||||
result.add(changeSet.toActivityItem(scope))
|
||||
}
|
||||
}
|
||||
return result
|
||||
|
||||
@@ -68,7 +68,9 @@ activity.list.empty.text.recent.matching=No matching recent activity detected
|
||||
activity.list.empty.text.in.scope=No activity in {0} detected
|
||||
activity.list.empty.text.in.scope.matching=No matching activity in {0} detected
|
||||
activity.list.empty.text.loading=Loading\u2026
|
||||
activity.item.presentation.from.paths={0} + {1} more
|
||||
activity.item.presentation=Changes
|
||||
activity.item.presentation.from.path=Changes in {0}
|
||||
activity.item.presentation.from.paths=Changes in {0} + {1} more
|
||||
activity.filter.empty.text.content=Search by content
|
||||
activity.filter.empty.text.fileName=Search by file name
|
||||
activity.diff.tab.title=Activity Diff
|
||||
|
||||
Reference in New Issue
Block a user