From d43b10514b971bd0fd4a55f0728d19c9c453a019 Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Sat, 13 Jul 2019 14:15:03 +0100 Subject: [PATCH] git: allow to change the path filter in the Update Info tab: IDEA-218028 If the Paths filter is not set (as it is initially), take the value from the Settings. Specifically handle the case when it is reset to All (when the filter is null). Don't persist filters: store them only for the current Update Info tab. GitOrigin-RevId: 40528c73aa62c3396606c368c7069b629c8bfae6 --- .../src/git4idea/update/GitUpdateInfoAsLog.kt | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/plugins/git4idea/src/git4idea/update/GitUpdateInfoAsLog.kt b/plugins/git4idea/src/git4idea/update/GitUpdateInfoAsLog.kt index 91fe98a84dd2..7205a30f4d4b 100644 --- a/plugins/git4idea/src/git4idea/update/GitUpdateInfoAsLog.kt +++ b/plugins/git4idea/src/git4idea/update/GitUpdateInfoAsLog.kt @@ -197,15 +197,31 @@ class GitUpdateInfoAsLog(private val project: Project, private class MyPropertiesForRange(val rangeFilter: VcsLogRangeFilter, val mainProperties: GitUpdateProjectInfoLogProperties) : MainVcsLogUiProperties by mainProperties { + private val filters: MutableMap> = TreeMap() + private var explicitlyRemovedPathsFilter = false + override fun getFilterValues(filterName: String): List? { when (filterName) { RANGE_FILTER.name -> return ArrayList(rangeFilter.getTextPresentation()) - STRUCTURE_FILTER.name, ROOT_FILTER.name -> return mainProperties.getFilterValues(filterName) - else -> return null + STRUCTURE_FILTER.name, ROOT_FILTER.name -> { + if (explicitlyRemovedPathsFilter) return null + return filters[filterName] ?: mainProperties.getFilterValues(filterName) + } + else -> return filters[filterName] } } override fun saveFilterValues(filterName: String, values: List?) { + if (values != null) { + filters[filterName] = values + } + else { + filters.remove(filterName) + } + + if (filterName == STRUCTURE_FILTER.name || filterName == ROOT_FILTER.name) { + explicitlyRemovedPathsFilter = values == null + } } }