From 13232ee81d237f799f76832e7ae2590fd9aadbb2 Mon Sep 17 00:00:00 2001 From: Aydar Mukhametzyanov Date: Wed, 1 Oct 2025 22:26:18 +0200 Subject: [PATCH] IJPL-204287 Fix the preview button after rebase GitOrigin-RevId: d52b67f5de679ac6081282c809e74c07e8c0bfe5 --- .../frontend/src/ui/SePopupContentPane.kt | 8 +++++--- .../searchEverywhere/frontend/src/ui/SePopupHeaderPane.kt | 7 +++---- platform/searchEverywhere/frontend/src/vm/SePopupVm.kt | 2 +- platform/searchEverywhere/frontend/src/vm/SeTabVm.kt | 6 ++---- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/platform/searchEverywhere/frontend/src/ui/SePopupContentPane.kt b/platform/searchEverywhere/frontend/src/ui/SePopupContentPane.kt index d6df006f5bcb..c4d595dd774d 100644 --- a/platform/searchEverywhere/frontend/src/ui/SePopupContentPane.kt +++ b/platform/searchEverywhere/frontend/src/ui/SePopupContentPane.kt @@ -286,11 +286,13 @@ class SePopupContentPane( } launch { - vm.currentTabFlow.collectLatest { - val filterEditor = it.filterEditor.getValue() + vm.currentTabFlow.collectLatest { tabVm -> + val filterEditor = tabVm.filterEditor.getValue() filterEditor?.let { filterEditor -> + val isPreviewEnabled = tabVm.isPreviewEnabled.getValue() + withContext(Dispatchers.EDT) { - headerPane.setFilterActions(filterEditor.getHeaderActions(), vm.ShowInFindToolWindowAction()) + headerPane.setFilterActions(filterEditor.getHeaderActions(), vm.ShowInFindToolWindowAction(), isPreviewEnabled) hintHelper.removeRightExtensions() val rightActions = filterEditor.getSearchFieldActions() if (rightActions.isNotEmpty()) { diff --git a/platform/searchEverywhere/frontend/src/ui/SePopupHeaderPane.kt b/platform/searchEverywhere/frontend/src/ui/SePopupHeaderPane.kt index 6bc989273ee0..90832ccc8679 100644 --- a/platform/searchEverywhere/frontend/src/ui/SePopupHeaderPane.kt +++ b/platform/searchEverywhere/frontend/src/ui/SePopupHeaderPane.kt @@ -69,7 +69,7 @@ class SePopupHeaderPane( } .component - setFilterActions(emptyList(), null) + setFilterActions(emptyList(), null, false) cell(tabFilterContainer).align(AlignY.FILL + AlignX.RIGHT).resizableColumn() } @@ -135,17 +135,16 @@ class SePopupHeaderPane( super.removeNotify() } - fun setFilterActions(actions: List, showInFindToolWindowAction: AnAction? = null) { + fun setFilterActions(actions: List, showInFindToolWindowAction: AnAction?, isPreviewEnabled: Boolean) { toolbarListenerDisposable?.let { Disposer.dispose(it) } val toolbarListenerDisposable = Disposer.newDisposable() this.toolbarListenerDisposable = toolbarListenerDisposable val actionGroup = DefaultActionGroup(actions) - showInFindToolWindowAction?.let { actionGroup.add(it) } if (isPreviewEnabled) { actionGroup.add(PreviewAction()) } - actionGroup.add(showInFindToolWindowAction) + showInFindToolWindowAction?.let { actionGroup.add(it) } toolbar = ActionManager.getInstance().createActionToolbar("search.everywhere.toolbar", actionGroup, true) toolbar.setLayoutStrategy(ToolbarLayoutStrategy.NOWRAP_STRATEGY) toolbar.targetComponent = this diff --git a/platform/searchEverywhere/frontend/src/vm/SePopupVm.kt b/platform/searchEverywhere/frontend/src/vm/SePopupVm.kt index fc3a5e9428aa..388751bb8bb2 100644 --- a/platform/searchEverywhere/frontend/src/vm/SePopupVm.kt +++ b/platform/searchEverywhere/frontend/src/vm/SePopupVm.kt @@ -158,7 +158,7 @@ class SePopupVm( if (PreviewExperiment.isExperimentEnabled && previewFetcher != null) { previewConfigurationFlow = combine(currentTabFlow, showPreviewSetting) { tabVm, previewSetting -> - tabVm.isPreviewEnabled() to previewSetting + tabVm.isPreviewEnabled.getValue() to previewSetting }.mapLatest { (tabPreviewEnabled, previewSetting) -> if (tabPreviewEnabled) { if (previewSetting) SePreviewConfiguration(previewFetcher.project, this::fetchPreview) diff --git a/platform/searchEverywhere/frontend/src/vm/SeTabVm.kt b/platform/searchEverywhere/frontend/src/vm/SeTabVm.kt index 56f9c7282f74..ebe4e70774e2 100644 --- a/platform/searchEverywhere/frontend/src/vm/SeTabVm.kt +++ b/platform/searchEverywhere/frontend/src/vm/SeTabVm.kt @@ -26,6 +26,7 @@ import com.intellij.platform.searchEverywhere.providers.SeAdaptedItem import com.intellij.platform.searchEverywhere.providers.SeLog import com.intellij.platform.searchEverywhere.utils.SuspendLazyProperty import com.intellij.platform.searchEverywhere.utils.initAsync +import com.intellij.platform.searchEverywhere.utils.suspendLazy import kotlinx.coroutines.* import kotlinx.coroutines.flow.* import org.jetbrains.annotations.ApiStatus @@ -51,6 +52,7 @@ class SeTabVm( else SearchEverywhereUsageTriggerCollector.NOT_REPORTABLE_ID val isIndexingDependent: Boolean get() = tab.isIndexingDependent + val isPreviewEnabled: SuspendLazyProperty get() = suspendLazy { tab.isPreviewEnabled() } private val shouldLoadMoreFlow: MutableStateFlow = MutableStateFlow(false) var shouldLoadMore: Boolean @@ -236,10 +238,6 @@ class SeTabVm( return tab.performExtendedAction(item) } - suspend fun isPreviewEnabled(): Boolean { - return tab.isPreviewEnabled() - } - suspend fun getPreviewInfo(itemData: SeItemData): SePreviewInfo? = tab.getPreviewInfo(itemData) }