From 588a63565ff2fc4679d51c6ca75ae9f52008bf49 Mon Sep 17 00:00:00 2001 From: "Andrei.Kuznetsov" Date: Mon, 27 May 2024 11:05:19 +0200 Subject: [PATCH] Fix indexing progress indicator fraction can be greater than 1.0 This commit fixes a bug introduced in aa4d0ffd128016a5201aefe4ccd8b5c532beb1f9: IJPL-425: IndexUpdateRunner refactoring: move `oneMoreFileProcessed` invocation from indexOneFileOfJob to the caller GitOrigin-RevId: a866f0c2f22a162d02f67ce7d10e623a492ed193 --- .../util/indexing/contentQueue/IndexUpdateRunner.kt | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/util/indexing/contentQueue/IndexUpdateRunner.kt b/platform/lang-impl/src/com/intellij/util/indexing/contentQueue/IndexUpdateRunner.kt index 6bbe6df37a4f..38762eaae466 100644 --- a/platform/lang-impl/src/com/intellij/util/indexing/contentQueue/IndexUpdateRunner.kt +++ b/platform/lang-impl/src/com/intellij/util/indexing/contentQueue/IndexUpdateRunner.kt @@ -142,8 +142,9 @@ class IndexUpdateRunner(fileBasedIndex: FileBasedIndexImpl, // and since there is no progress indicator, we don't need "originalSuspender.executeNonSuspendableSection" // (there is no way to access originalSuspender or indicator from inside indexOneFileOfJob) - indexOneFileOfJob(indexingJob) - indexingJob.oneMoreFileProcessed() // indexOneFileOfJob may throw, then this line is not executed, and this is what we need. + if (indexOneFileOfJob(indexingJob)) { + indexingJob.oneMoreFileProcessed() + } if (IndexUpdateWriter.WRITE_INDEXES_ON_SEPARATE_THREAD) { // TODO: suspend, not block @@ -158,12 +159,12 @@ class IndexUpdateRunner(fileBasedIndex: FileBasedIndexImpl, } @Throws(ProcessCanceledException::class) - private fun indexOneFileOfJob(indexingJob: IndexingJob) { + private fun indexOneFileOfJob(indexingJob: IndexingJob): Boolean { val startTime = System.nanoTime() val fileIndexingJob = indexingJob.myQueueOfFiles.poll() if (fileIndexingJob == null) { - return + return false } try { @@ -203,6 +204,8 @@ class IndexUpdateRunner(fileBasedIndex: FileBasedIndexImpl, To reindex this file IDEA has to be restarted """.trimIndent(), e) } + + return true } @ApiStatus.Internal