From a43c389c4630fa7b39195c866607bd21f0ece5fb Mon Sep 17 00:00:00 2001 From: Aleksey Pivovarov Date: Wed, 9 Feb 2022 14:03:52 +0300 Subject: [PATCH] cwm: fix empty diff preview in remote development CLM refresh event might come with host ClientId, while preview file is opened for unattended guest. GitOrigin-RevId: 0ec0256062fd9eda3f3c2d9db2a06b42e5d08e05 --- .../openapi/fileEditor/FileEditorManager.java | 11 ++++++++++- .../intellij/openapi/vcs/changes/EditorTabPreview.kt | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/platform/analysis-api/src/com/intellij/openapi/fileEditor/FileEditorManager.java b/platform/analysis-api/src/com/intellij/openapi/fileEditor/FileEditorManager.java index 6907eb476ff4..12c11d9bf1a6 100644 --- a/platform/analysis-api/src/com/intellij/openapi/fileEditor/FileEditorManager.java +++ b/platform/analysis-api/src/com/intellij/openapi/fileEditor/FileEditorManager.java @@ -93,6 +93,15 @@ public abstract class FileEditorManager { */ public abstract boolean isFileOpen(@NotNull VirtualFile file); + /** + * @return {@code true} if {@code file} is opened, {@code false} otherwise + * Unlike {@link #isFileOpen(VirtualFile)} includes files which were opened by all guests during a collaborative development session. + */ + @ApiStatus.Experimental + public boolean isFileOpenWithRemotes(@NotNull VirtualFile file) { + return isFileOpen(file); + } + /** * @return all opened files. Order of files in the array corresponds to the order of editor tabs. */ @@ -263,5 +272,5 @@ public abstract class FileEditorManager { * * @param file the file to refresh. */ - public void updateFilePresentation(@NotNull VirtualFile file) {} + public void updateFilePresentation(@NotNull VirtualFile file) { } } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/EditorTabPreview.kt b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/EditorTabPreview.kt index 42709b647931..7836b5698159 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/EditorTabPreview.kt +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/EditorTabPreview.kt @@ -132,7 +132,7 @@ abstract class EditorTabPreview(protected val diffProcessor: DiffRequestProcesso if (isPreviewVisible) openPreview(focus) else closePreview() } - protected fun isPreviewOpen(): Boolean = FileEditorManager.getInstance(project).isFileOpen(previewFile) + protected fun isPreviewOpen(): Boolean = FileEditorManager.getInstance(project).isFileOpenWithRemotes(previewFile) fun closePreview() { FileEditorManager.getInstance(project).closeFile(previewFile)