IJPL-188383 Search Everywhere, All tab: 'Top Hit' filter is duplicated

(cherry picked from commit 1954d2ad0712b4cee9de50aedbf00ef782c5c18f)

IJ-CR-169646

GitOrigin-RevId: be62d6d4c1265b1dd4043c95e0a3b01acbc16b8b
This commit is contained in:
Aydar Mukhametzyanov
2025-07-17 15:27:19 +02:00
committed by intellij-monorepo-bot
parent 200d15fa4f
commit 830a094ed8
2 changed files with 22 additions and 1 deletions

View File

@@ -45,6 +45,7 @@ class SeTabDelegate(
fun getItems(params: SeParams, disabledProviders: List<SeProviderId>? = null): Flow<SeResultEvent> {
val accumulator = SeResultsAccumulator(providersAndLimits)
val disabledProviders = fixDisabledProviders(disabledProviders)
return flow {
disabledProviders?.forEach {
@@ -202,6 +203,20 @@ class SeTabDelegate(
}
}
// Workaround for: IJPL-188383 Search Everywhere, All tab: 'Top Hit' filter is duplicated
// Add/remove Top Hit (On Client) according to the presence of Top Hit provider
private fun fixDisabledProviders(disabledProviders: List<SeProviderId>?): List<SeProviderId>? {
val all = disabledProviders?.toMutableSet() ?: return null
val topHitClientId = SeProviderIdUtils.TOP_HIT_ID.toProviderId()
if (all.contains(SeProviderIdUtils.TOP_HIT_HOST_ID.toProviderId())) {
all.add(topHitClientId)
}
else all.remove(topHitClientId)
return all.toList()
}
companion object {
suspend fun shouldShowLegacyContributorInSeparateTab(
project: Project,

View File

@@ -103,7 +103,13 @@ private class SeAllFilterEditor(providersIdToName: Map<SeProviderId, @Nls String
}
private fun getFilterTypesAction(providersIdToName: Map<SeProviderId, @Nls String>): AnAction {
val namesMap = providersIdToName.map { it.key.value to it.value }.toMap()
val namesMap = providersIdToName.mapNotNull {
// Workaround for: IJPL-188383 Search Everywhere, All tab: 'Top Hit' filter is duplicated
// Don't add 'Top Hit (On Client)' to the list of providers
if (it.key.value == SeProviderIdUtils.TOP_HIT_ID) return@mapNotNull null
it.key.value to it.value
}.toMap()
val configuration = SearchEverywhereConfiguration.getInstance()
val persistentFilter =