[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
This commit is contained in:
Sergei Tachenov
2025-11-10 20:00:27 +00:00
committed by intellij-monorepo-bot
parent e25a7af880
commit 4e9303dcd7
@@ -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