From b5aa6a9dee0791aab663bf7042e587097c7f66d1 Mon Sep 17 00:00:00 2001 From: Aydar Mukhametzyanov Date: Fri, 20 Feb 2026 18:35:32 +0100 Subject: [PATCH] [platform UI][se] IJPL-227351 Search everywhere: preview window disappears (cherry picked from commit 1744e4a611640900e68b9accd19350f59fd427f8) IJ-CR-192757 GitOrigin-RevId: f2cb6e1524bd33e2af9f979575c53975244b850b --- .../frontend/src/ui/SePopupContentPane.kt | 27 ++++++++++--------- .../frontend/src/vm/SePopupVm.kt | 13 +++------ 2 files changed, 18 insertions(+), 22 deletions(-) diff --git a/platform/searchEverywhere/frontend/src/ui/SePopupContentPane.kt b/platform/searchEverywhere/frontend/src/ui/SePopupContentPane.kt index 30de961c3700..b99303bf42ab 100644 --- a/platform/searchEverywhere/frontend/src/ui/SePopupContentPane.kt +++ b/platform/searchEverywhere/frontend/src/ui/SePopupContentPane.kt @@ -477,21 +477,22 @@ class SePopupContentPane( vm.previewConfigurationFlow.collectLatest { configuration -> val isVisible = configuration?.fetchPreview != null - withContext(Dispatchers.EDT) { - usagePreviewPanel?.isVisible = isVisible + if (!isVisible) { + withContext(Dispatchers.EDT) { + usagePreviewPanel?.isVisible = false + } + return@collectLatest } - if (isVisible) { - selectedItemDataFlow.collectLatest { itemData -> - withContext(Dispatchers.EDT) { - if (itemData != null) { - val usageInfos = configuration.fetchPreview(itemData) - usagePreviewPanel?.isVisible = true - usagePreviewPanel?.updateLayout(configuration.project, usageInfos) - } - else { - usagePreviewPanel?.isVisible = false - } + selectedItemDataFlow.collectLatest { itemData -> + withContext(Dispatchers.EDT) { + if (itemData != null) { + val usageInfos = configuration.fetchPreview(itemData) + usagePreviewPanel?.isVisible = true + usagePreviewPanel?.updateLayout(configuration.project, usageInfos) + } + else { + usagePreviewPanel?.isVisible = false } } } diff --git a/platform/searchEverywhere/frontend/src/vm/SePopupVm.kt b/platform/searchEverywhere/frontend/src/vm/SePopupVm.kt index 314dfffd8dbb..167012ee49ac 100644 --- a/platform/searchEverywhere/frontend/src/vm/SePopupVm.kt +++ b/platform/searchEverywhere/frontend/src/vm/SePopupVm.kt @@ -56,7 +56,6 @@ import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.flatMapLatest import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.flow.map -import kotlinx.coroutines.flow.mapLatest import kotlinx.coroutines.flow.update import kotlinx.coroutines.joinAll import kotlinx.coroutines.launch @@ -232,16 +231,12 @@ class SePopupVm( ) if (PreviewExperiment.isExperimentEnabled && previewFetcher != null) { - previewConfigurationFlow = combine(currentTabFlow, showPreviewSetting) { tabVm, previewSetting -> - tabVm.isPreviewEnabled.getValue() to previewSetting - }.mapLatest { (tabPreviewEnabled, previewSetting) -> - if (tabPreviewEnabled) { - if (previewSetting) SePreviewConfiguration(previewFetcher.project, this::fetchPreview) + previewConfigurationFlow = currentTabFlow.flatMapLatest { tabVm -> + val tabPreviewEnabled = tabVm.isPreviewEnabled.getValue() + showPreviewSetting.map { previewSetting -> + if (tabPreviewEnabled && previewSetting) SePreviewConfiguration(previewFetcher.project, this::fetchPreview) else SePreviewConfiguration(previewFetcher.project, null) } - else { - SePreviewConfiguration(previewFetcher.project, null) - } } } else {