From 837bf09c88e7f00f6a4299cd38e3d720302d5378 Mon Sep 17 00:00:00 2001 From: Sergei Kharitontcev-Beglov Date: Fri, 12 Sep 2025 15:52:44 +0200 Subject: [PATCH] [rdct] IJPL-196175 IJPL-202195: Use `WriteAction` for file opening if in the modal progress If the file is opened on EDT under the modal progress, the race could happen between modal progress and `blockingWaitForCompositeFileOpen`: 1. `blockingWaitForCompositeFileOpen` starts with already showing modal progress dialog 2. The pumping inside the function wants to pump the modal dialog and check after it if the initialization job is done 3. The modal dialog waits until all its subroutines (including one that pumps EDT) are finished, thus the EDT will never be pumped. This bug is similar to the IDEA-319932, where navigation was done under the write action. However, in this case there's no write action, but just Dialog's UI. The temporary fix to this problem is to open the file under write action if there's any modality GitOrigin-RevId: d9b61bfdefc1dbf51deca146a52160049748da8e --- .../openapi/fileEditor/impl/FileEditorManagerImpl.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileEditorManagerImpl.kt b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileEditorManagerImpl.kt index 7f5bed44f139..233dd52ffde5 100644 --- a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileEditorManagerImpl.kt +++ b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileEditorManagerImpl.kt @@ -115,7 +115,6 @@ import java.util.concurrent.atomic.LongAdder import javax.swing.JComponent import javax.swing.JTabbedPane import javax.swing.KeyStroke -import kotlin.math.max import kotlin.time.Duration.Companion.milliseconds private val LOG = logger() @@ -2506,12 +2505,13 @@ fun blockingWaitForCompositeFileOpen(composite: EditorComposite) { job.invokeOnCompletion { EventQueue.invokeLater(EmptyRunnable.getInstance()) } - IdeEventQueue.getInstance().pumpEventsForHierarchy { job.isCompleted } + job.join() } - } finally { + } + finally { cleanup() } }