From 4e9303dcd735585fd39ceeacade6d6a620402c19 Mon Sep 17 00:00:00 2001 From: Sergei Tachenov Date: Mon, 10 Nov 2025 16:39:35 +0200 Subject: [PATCH] [UI, editor, remdev] IJPL-216969 Fix right split opening in CWM When running under a non-local client ID, delegate to the client editor manager right away without messing with local splitters. It worked in regular remdev because there are no local splitters there, but in CWM it didn't work. GitOrigin-RevId: b773743466913ef71eeb71161b1eabc1e5bb78cc --- .../fileEditor/impl/FileEditorManagerImpl.kt | 29 +++++++------------ 1 file changed, 11 insertions(+), 18 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 fd94b5c0713f..5662b1220c88 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 @@ -921,6 +921,15 @@ open class FileEditorManagerImpl( } override suspend fun openFile(file: VirtualFile, options: FileEditorOpenOptions): FileEditorComposite { + if (!ClientId.isCurrentlyUnderLocalId) { + return clientFileEditorManager?.openFileAsync( + file = file, + // it used to be passed as forceCreate=false there, so we need to pass it as reuseOpen=true + // otherwise, any navigation will open a new editor composite which is invisible in RD mode + options = options.copy(reuseOpen = true), + ) ?: FileEditorComposite.EMPTY + } + val mode = options.openMode if (mode == OpenMode.NEW_WINDOW) { return withContext(Dispatchers.EDT) { @@ -951,19 +960,13 @@ open class FileEditorManagerImpl( } } - val isCurrentlyUnderLocalId = ClientId.isCurrentlyUnderLocalId - - var composite: FileEditorComposite? = withContext(Dispatchers.EDT) { + val composite: FileEditorComposite? = withContext(Dispatchers.EDT) { writeIntentReadAction { val window = getWindowToOpen(options, file) if (forbidSplitFor(file) && !window.isFileOpen(file)) { closeFile(file) } - if (!isCurrentlyUnderLocalId) { - return@writeIntentReadAction null - } - @Suppress("DuplicatedCode") runBulkTabChangeInEdt(window.owner) { doOpenInEdt(window = window, file = file, options = options, fileEntry = null) @@ -971,21 +974,11 @@ open class FileEditorManagerImpl( } } - if (composite == null) { - assert(!isCurrentlyUnderLocalId) - composite = clientFileEditorManager?.openFileAsync( - file = file, - // it used to be passed as forceCreate=false there, so we need to pass it as reuseOpen=true - // otherwise, any navigation will open a new editor composite which is invisible in RD mode - options = options.copy(reuseOpen = true), - ) ?: FileEditorComposite.EMPTY - } - // The client of the `openFile` API expects an editor to be available after invocation, so we wait until the file is opened if (composite is EditorComposite) { composite.waitForAvailable() } - return composite + return composite ?: FileEditorComposite.EMPTY } @ApiStatus.Internal