From 9deaa2e1b26c986301c57277eeefb903a2f38433 Mon Sep 17 00:00:00 2001 From: Ilia Malakhov Date: Wed, 21 Jan 2026 15:37:56 +0100 Subject: [PATCH] IJPL-224359 fix tests searching for more files than expected SearchEverywhereContributor.search searches for elementsLimit + 1, so in tests where search was expected to finish quickly after it found 1 file, it continued searching. Setting elementsLimit to 0 instead of 1 removes the issue Space-RevId: ac6852d582b35f2ee4ae9cad71ba72159f90ab52 GitOrigin-RevId: e27d7cee7f03a0bdb084227503e8dadea1fa32c1 --- .../NonIndexableFileSearchPerformanceTest.kt | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/platform/platform-tests/testSrc/com/intellij/ide/actions/searcheverywhere/NonIndexableFileSearchPerformanceTest.kt b/platform/platform-tests/testSrc/com/intellij/ide/actions/searcheverywhere/NonIndexableFileSearchPerformanceTest.kt index d5134ca078a0..d5a9425db3e5 100644 --- a/platform/platform-tests/testSrc/com/intellij/ide/actions/searcheverywhere/NonIndexableFileSearchPerformanceTest.kt +++ b/platform/platform-tests/testSrc/com/intellij/ide/actions/searcheverywhere/NonIndexableFileSearchPerformanceTest.kt @@ -105,7 +105,10 @@ open class NonIndexableFileSearchPerformanceTest { val searchPattern = "ProjectRootEntity" val contributor = createContributor() Benchmark.newBenchmarkWithVariableInputSize("search \"$searchPattern\"", nonIndexableFilesCount) { - contributor.search(searchPattern, MockProgressIndicator(), 1) + // elementsLimit = 0, so when the first matching file is found, the search stops. + // Because it actually searches for `elementsLimit + 1` files + val elementsLimit = 0 + contributor.search(searchPattern, MockProgressIndicator(), elementsLimit) nonIndexableFilesCount }.start(NonIndexableFileSearchPerformanceTest::`search for one file deep inside`.javaMethod!!, subtestName) } @@ -139,7 +142,10 @@ open class NonIndexableFileSearchPerformanceTest { val filename = communityVirtualFile.getChildren(true).last().name val contributor = createContributor() Benchmark.newBenchmarkWithVariableInputSize("search \"$filename\"", nonIndexableFilesCount) { - contributor.search(filename, MockProgressIndicator(), 1) + // elementsLimit = 0, so when the first matching file is found, the search stops. + // Because it actually searches for `elementsLimit + 1` files + val elementsLimit = 0 + contributor.search(filename, MockProgressIndicator(), elementsLimit) nonIndexableFilesCount }.start(NonIndexableFileSearchPerformanceTest::`search for one last root child`.javaMethod!!, subtestName) } @@ -173,7 +179,10 @@ open class NonIndexableFileSearchPerformanceTest { val filename = communityVirtualFile.getChildren(true).first().name val contributor = createContributor() Benchmark.newBenchmark("search \"$filename\"") { - contributor.search(filename, MockProgressIndicator(), 1) + // elementsLimit = 0, so when the first matching file is found, the search stops. + // Because it actually searches for `elementsLimit + 1` files + val elementsLimit = 0 + contributor.search(filename, MockProgressIndicator(), elementsLimit) }.start(NonIndexableFileSearchPerformanceTest::`search for the first root child`.javaMethod!!, subtestName) }