diff --git a/platform/lang-impl/src/com/intellij/find/impl/FindPopupPanel.java b/platform/lang-impl/src/com/intellij/find/impl/FindPopupPanel.java index b66a1bc2c6b4..a556b6d9abde 100644 --- a/platform/lang-impl/src/com/intellij/find/impl/FindPopupPanel.java +++ b/platform/lang-impl/src/com/intellij/find/impl/FindPopupPanel.java @@ -1340,14 +1340,17 @@ public final class FindPopupPanel extends JBPanel implements Fin public void onFinish() { ApplicationManager.getApplication().invokeLater(() -> { + boolean isEmpty = resultsCount.get() == 0; + if (!isCancelled()) { - boolean isEmpty = resultsCount.get() == 0; if (isEmpty) { showEmptyText(FindBundle.message("message.nothingFound"), true); } } FindUsagesCollector.recordSearchFinished(System.currentTimeMillis() - startTime.get(), resultsCount.get(), ShowUsagesAction.getUsagesPageSize()); onStop(hash); + + myHelper.onSearchFinish(isEmpty ? 0 : myResultsPreviewTable.getRowCount()); }, state); } }, myResultsPreviewSearchProgress); @@ -1572,7 +1575,6 @@ public final class FindPopupPanel extends JBPanel implements Fin if (backendValidator.isFinished) { header.loadingIcon.setIcon(EmptyIcon.ICON_16); } - myHelper.onSearchStop(); }); } diff --git a/platform/lang-impl/src/com/intellij/find/impl/FindUIHelper.java b/platform/lang-impl/src/com/intellij/find/impl/FindUIHelper.java index 6f656fe8071e..4240d79f683c 100644 --- a/platform/lang-impl/src/com/intellij/find/impl/FindUIHelper.java +++ b/platform/lang-impl/src/com/intellij/find/impl/FindUIHelper.java @@ -16,6 +16,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; +import java.util.function.Consumer; @SuppressWarnings("WeakerAccess") public final class FindUIHelper implements Disposable { @@ -23,7 +24,7 @@ public final class FindUIHelper implements Disposable { private @NotNull FindModel myModel; FindModel myPreviousModel; private @NotNull Runnable myOkHandler; - private @Nullable Runnable myStopHandler; + private @Nullable Consumer myFinishHandler; FindUI myUI; @@ -172,14 +173,14 @@ public final class FindUIHelper implements Disposable { } @ApiStatus.Internal - public void setStopHandler(@Nullable Runnable stopHandler) { - myStopHandler = stopHandler; + public void setFinishHandler(@Nullable Consumer finishHandler) { + myFinishHandler = finishHandler; } @ApiStatus.Internal - public void onSearchStop() { - if (myStopHandler != null) { - myStopHandler.run(); + public void onSearchFinish(int count) { + if (myFinishHandler != null) { + myFinishHandler.accept(count); } } } diff --git a/plugins/performanceTesting/core/src/com/jetbrains/performancePlugin/commands/FindInFilesCommand.kt b/plugins/performanceTesting/core/src/com/jetbrains/performancePlugin/commands/FindInFilesCommand.kt index 14f8498596c1..8bcc146f7d51 100644 --- a/plugins/performanceTesting/core/src/com/jetbrains/performancePlugin/commands/FindInFilesCommand.kt +++ b/plugins/performanceTesting/core/src/com/jetbrains/performancePlugin/commands/FindInFilesCommand.kt @@ -66,7 +66,7 @@ class FindInFilesCommand(text: String, line: Int) : PlaybackCommandCoroutineAdap val findSpan = PerformanceTestSpan.TRACER.spanBuilder("$SEARCH_SPAN_NAME: $it").startSpan() val findMutex = Mutex(true) - findHelper.setStopHandler { + findHelper.setFinishHandler { resultsCount -> findSpan.end() findHelper.closeUI() findMutex.unlock()