From 3cb1453485b69a37d85815d5e5cbcb98b7d46b56 Mon Sep 17 00:00:00 2001 From: Andrey Loskutov Date: Thu, 15 Feb 2024 15:18:20 +0100 Subject: [PATCH] Don't consider "unassociated" child content types while matching files Fixes https://github.com/eclipse-platform/eclipse.platform/issues/1207 --- .../internal/content/ContentTypeCatalog.java | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/runtime/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/internal/content/ContentTypeCatalog.java b/runtime/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/internal/content/ContentTypeCatalog.java index 4e1dc42e8ac..8359e391f1d 100644 --- a/runtime/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/internal/content/ContentTypeCatalog.java +++ b/runtime/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/internal/content/ContentTypeCatalog.java @@ -711,16 +711,20 @@ private Set selectMatchingByName(final IScopeContext context, Colle internalAccept(new ContentTypeVisitor() { @Override public int visit(ContentType type) { - if (type != root && type.hasBuiltInAssociations()) + if (type != root && type.hasBuiltInAssociations()) { // this content type has built-in associations - visit it later as root return RETURN; - if (type == root && !type.hasFileSpec(context, fileSpecText, fileSpecType)) - // it is the root and does not match the file name - do not add it nor look into its children - return RETURN; - // either the content type is the root and matches the file name or - // is a sub content type and does not have built-in files specs - if (!existing.contains(type)) - destination.add(type); + } + if (type == root) { + if (!type.hasFileSpec(context, fileSpecText, fileSpecType)) { + // it is the root and does not match the file name - do not add it nor look into its children + return RETURN; + } + // the content type is the root and matches the file name + if (!existing.contains(type)) { + destination.add(type); + } + } return CONTINUE; } }, root);