From 0f64336d2bc4c785643f38d429bd36bdbae0337e Mon Sep 17 00:00:00 2001 From: Andrey Loskutov Date: Tue, 2 Jul 2024 18:46:33 +0200 Subject: [PATCH] Clean up code in findEditorLinkedDescriptors() As noted on PR #1277, the code looks weird and I can't explain what I smoke while writing it. Fixed the code to do what actually was meant. This is mostly paranoia code, as usually input.getName() is not null. See https://github.com/eclipse-platform/eclipse.platform/pull/1277 See https://github.com/eclipse-platform/eclipse.platform.ui/issues/1747 --- .../org/eclipse/compare/internal/CompareUIPlugin.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java index 86c92651ba0..bbf6e35934b 100644 --- a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java +++ b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java @@ -1118,12 +1118,11 @@ private static void ensureTextIsLast(LinkedHashSet result) { */ Set findEditorLinkedDescriptors(String fileName, IContentType contentType, boolean firstIsEnough) { - if (fileName == null) { - if (contentType == null) { - contentType = fgContentTypeManager.findContentTypeFor(fileName); - } else { - return Collections.emptySet(); - } + if (fileName == null && contentType == null) { + return Collections.emptySet(); + } + if (contentType == null) { + contentType = fgContentTypeManager.findContentTypeFor(fileName); } LinkedHashSet viewers = fContentMergeViewers.getAll().stream()