Skip to content

Commit 87a9b91

Browse files
dovchinnikovintellij-monorepo-bot
authored andcommitted
IDEA-327274 Revert "IDEA-338005 call indicator.start after the progress indicator is shown"
This reverts commit d2576dd2d846daa0b022e91991660fee85f03280. Consider this piece: ``` withContext(Dispatchers.EDT) { showIndicatorInUI(project, taskInfo, indicator) } ``` `showIndicatorInUI` was completed but `withContext` resumed with `CancellationException` if the coroutine is cancelled concurrently, which happens if the task takes about 300ms and completes while `showIndicatorInUI` is executed. `CancellationException` from `withContext` prevented `indicator.finish`. `withContext` resuming with CE even if block completed without CE is tracked here: Kotlin/kotlinx.coroutines#3504 GitOrigin-RevId: e684335dcb7bb2eb8abb7399eec7cdf1788470d2
1 parent dec608b commit 87a9b91

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

platform/platform-impl/src/com/intellij/openapi/progress/impl/PlatformTaskSupport.kt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -188,19 +188,19 @@ private fun CoroutineScope.showIndicator(
188188
delay(DEFAULT_PROGRESS_DIALOG_POSTPONE_TIME_MILLIS.toLong())
189189
tracer.spanBuilder("Progress: ${taskInfo.title}").startSpan().use {
190190
val indicator = coroutineCancellingIndicator(taskJob) // cancel taskJob from UI
191-
val indicatorAdded = withContext(Dispatchers.EDT) {
192-
showIndicatorInUI(project, taskInfo, indicator)
193-
}
194-
if (indicatorAdded) {
195-
indicator.start()
196-
try {
197-
indicator.updateFromFlow(stateFlow)
191+
indicator.start()
192+
try {
193+
val indicatorAdded = withContext(Dispatchers.EDT) {
194+
showIndicatorInUI(project, taskInfo, indicator)
198195
}
199-
finally {
200-
indicator.stop()
201-
indicator.finish(taskInfo)
196+
if (indicatorAdded) {
197+
indicator.updateFromFlow(stateFlow)
202198
}
203199
}
200+
finally {
201+
indicator.stop()
202+
indicator.finish(taskInfo)
203+
}
204204
}
205205
}
206206
}

0 commit comments

Comments
 (0)