From 10ffbf0ca9cb1a12be157b09c8d257dcec199041 Mon Sep 17 00:00:00 2001 From: Sergei Kharitontcev-Beglov Date: Wed, 4 Mar 2026 12:01:29 +0100 Subject: [PATCH] IJPL-237895 search-everywhere: Use KeepAlive in the document right before the item is selected This commit fixes a bug when a rapid editor close on the frontend and navigation on the backend could conflict and skip editor to be opened. This commit introduced the Rider's keep alive workaround for same problem (cherry-picked from f4144e1819baa6f30d25a8d38cfdebe3d8df06e0) (cherry picked from commit 5ed488db9b341dd48a8f6421e54e931a214ba548) IJ-MR-195270 GitOrigin-RevId: 7ae16f504516391e08c4ed06b4acf8501ad00ae9 --- ...lij.platform.searchEverywhere.frontend.xml | 4 ++++ .../src/SeFrontendItemDataProvidersFacade.kt | 4 +++- .../frontend/src/SePreviewPanelListener.kt | 23 +++++++++++++++++++ .../frontend/src/ui/SePopupContentPane.kt | 3 ++- 4 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 platform/searchEverywhere/frontend/src/SePreviewPanelListener.kt diff --git a/platform/searchEverywhere/frontend/resources/intellij.platform.searchEverywhere.frontend.xml b/platform/searchEverywhere/frontend/resources/intellij.platform.searchEverywhere.frontend.xml index cbd449b163e3..fb361d8efe5d 100644 --- a/platform/searchEverywhere/frontend/resources/intellij.platform.searchEverywhere.frontend.xml +++ b/platform/searchEverywhere/frontend/resources/intellij.platform.searchEverywhere.frontend.xml @@ -12,6 +12,10 @@ + + diff --git a/platform/searchEverywhere/frontend/src/SeFrontendItemDataProvidersFacade.kt b/platform/searchEverywhere/frontend/src/SeFrontendItemDataProvidersFacade.kt index 0d8ea6f0b961..c7c6bc8d6849 100644 --- a/platform/searchEverywhere/frontend/src/SeFrontendItemDataProvidersFacade.kt +++ b/platform/searchEverywhere/frontend/src/SeFrontendItemDataProvidersFacade.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2026 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.platform.searchEverywhere.frontend import com.intellij.ide.rpc.DataContextId @@ -11,6 +11,7 @@ import com.intellij.platform.searchEverywhere.SeSession import com.intellij.platform.searchEverywhere.SeTransferEnd import com.intellij.platform.searchEverywhere.SeTransferEvent import com.intellij.platform.searchEverywhere.SeTransferItem +import com.intellij.platform.searchEverywhere.frontend.ui.SePreviewPanelListener import com.intellij.platform.searchEverywhere.impl.SeRemoteApi import com.intellij.platform.searchEverywhere.presentations.SeItemPresentation import com.intellij.platform.searchEverywhere.providers.SeLog @@ -72,6 +73,7 @@ class SeFrontendItemDataProvidersFacade(private val projectId: ProjectId, modifiers: Int, searchText: String, ): Boolean { + SePreviewPanelListener.EP.forEachExtensionSafe { it.onItemSelected() } return SeRemoteApi.getInstance().itemSelected(projectId, session, itemData, modifiers, searchText, isAllTab = isAllTab) } diff --git a/platform/searchEverywhere/frontend/src/SePreviewPanelListener.kt b/platform/searchEverywhere/frontend/src/SePreviewPanelListener.kt new file mode 100644 index 000000000000..ad02d93a3ef1 --- /dev/null +++ b/platform/searchEverywhere/frontend/src/SePreviewPanelListener.kt @@ -0,0 +1,23 @@ +// Copyright 2000-2026 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +package com.intellij.platform.searchEverywhere.frontend.ui + +import com.intellij.openapi.editor.Editor +import com.intellij.openapi.extensions.ExtensionPointName +import org.jetbrains.annotations.ApiStatus + +/** + * A very internal hack for fixing IJPL-237895. A subject to removal. Please do not use it. + */ +@ApiStatus.Internal +@FunctionalInterface +interface SePreviewPanelListener { + companion object { + val EP: ExtensionPointName = ExtensionPointName.create("com.intellij.searchEverywhere.previewPanelListener") + } + + /** + * Called, when new [editor] is used to show a preview in Search Everywhere preview tab + */ + fun onNewPreviewEditor(editor: Editor) + fun onItemSelected() +} \ No newline at end of file diff --git a/platform/searchEverywhere/frontend/src/ui/SePopupContentPane.kt b/platform/searchEverywhere/frontend/src/ui/SePopupContentPane.kt index b99303bf42ab..cca7d7a00bf2 100644 --- a/platform/searchEverywhere/frontend/src/ui/SePopupContentPane.kt +++ b/platform/searchEverywhere/frontend/src/ui/SePopupContentPane.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2026 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.platform.searchEverywhere.frontend.ui import com.intellij.icons.AllIcons @@ -1073,6 +1073,7 @@ class SePopupContentPane( } override fun onEditorCreated(editor: Editor) { + SePreviewPanelListener.EP.forEachExtensionSafe { it.onNewPreviewEditor(editor) } if (editor is EditorEx) { editor.setRendererMode(true) }