diff --git a/plugins/git4idea/resources/messages/GitBundle.properties b/plugins/git4idea/resources/messages/GitBundle.properties index bb43983a83ea..c9739819c28c 100644 --- a/plugins/git4idea/resources/messages/GitBundle.properties +++ b/plugins/git4idea/resources/messages/GitBundle.properties @@ -399,7 +399,7 @@ stash.error=Failed to stash {0} # suppress inspection "UnusedProperty" - used in third-party plugins stashing.title=Stashing Changes\u2026 stashing.progress.title=Stashing changes\u2026 -stash.editor.diff.preview.title=Stash: {0} +stash.editor.diff.preview.id.change.title={0}: {1} stash.editor.diff.preview.empty.title=Stash stash.tab.name=Stash diff --git a/plugins/git4idea/src/git4idea/stash/ui/GitStashChangesBrowser.kt b/plugins/git4idea/src/git4idea/stash/ui/GitStashChangesBrowser.kt index eb045633e1b2..378f0eb19bc6 100644 --- a/plugins/git4idea/src/git4idea/stash/ui/GitStashChangesBrowser.kt +++ b/plugins/git4idea/src/git4idea/stash/ui/GitStashChangesBrowser.kt @@ -104,7 +104,9 @@ class GitStashChangesBrowser(project: Project, parentDisposable: Disposable) : C setData(stash, parents) { statusText -> statusText.text = "" } } - private fun setData(stash: Collection, parents: Collection, updateEmptyText: (StatusText) -> Unit) { + private fun setData(stash: Collection, + parents: Collection, + updateEmptyText: (StatusText) -> Unit) { stashedChanges = stash otherChanges = parents.associate { parent -> val tag = MyTag(StringUtil.capitalize(parent.subject.substringBefore(":")), parent.id) @@ -138,7 +140,14 @@ class GitStashChangesBrowser(project: Project, parentDisposable: Disposable) : C diffPreviewProcessor = newProcessor if (isInEditor) { - editorTabPreview = GitStashEditorDiffPreview(newProcessor, viewer, this) + editorTabPreview = object : GitStashEditorDiffPreview(newProcessor, viewer, this@GitStashChangesBrowser) { + override fun getCurrentName(): String { + return changeViewProcessor.currentChangeName?.let { changeName -> + val stashId = currentStash?.stash?.capitalize() ?: GitBundle.message("stash.editor.diff.preview.empty.title") + GitBundle.message("stash.editor.diff.preview.id.change.title", stashId, changeName) + } ?: GitBundle.message("stash.editor.diff.preview.empty.title") + } + } } else { editorTabPreview = null diff --git a/plugins/git4idea/src/git4idea/stash/ui/GitStashEditorDiffPreview.kt b/plugins/git4idea/src/git4idea/stash/ui/GitStashEditorDiffPreview.kt index e7ffba9e7827..e8ac1086aa42 100644 --- a/plugins/git4idea/src/git4idea/stash/ui/GitStashEditorDiffPreview.kt +++ b/plugins/git4idea/src/git4idea/stash/ui/GitStashEditorDiffPreview.kt @@ -1,21 +1,15 @@ -// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package git4idea.stash.ui import com.intellij.openapi.vcs.changes.ui.ChangesTree import com.intellij.openapi.vcs.changes.ui.ChangesViewContentManager import com.intellij.openapi.vcs.changes.ui.SimpleTreeEditorDiffPreview -import git4idea.i18n.GitBundle import javax.swing.JComponent -class GitStashEditorDiffPreview(diffProcessor: GitStashDiffPreview, tree: ChangesTree, targetComponent: JComponent) +abstract class GitStashEditorDiffPreview(diffProcessor: GitStashDiffPreview, tree: ChangesTree, targetComponent: JComponent) : SimpleTreeEditorDiffPreview(diffProcessor, tree, targetComponent, false) { override fun returnFocusToTree() { ChangesViewContentManager.getToolWindowFor(project, GitStashContentProvider.TAB_NAME)?.activate(null) } - - override fun getCurrentName(): String { - return changeViewProcessor.currentChangeName?.let { changeName -> GitBundle.message("stash.editor.diff.preview.title", changeName) } - ?: GitBundle.message("stash.editor.diff.preview.empty.title") - } }