Skip to content

Commit 9f85daf

Browse files
authored
[#808] Support overriden default-editor-association in EditorUtility (#809)
1 parent d8328fb commit 9f85daf

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
22
Bundle-ManifestVersion: 2
33
Bundle-Name: %pluginName
44
Bundle-SymbolicName: org.eclipse.cdt.ui; singleton:=true
5-
Bundle-Version: 8.1.400.qualifier
5+
Bundle-Version: 8.1.500.qualifier
66
Bundle-Activator: org.eclipse.cdt.ui.CUIPlugin
77
Bundle-Vendor: %providerName
88
Bundle-Localization: plugin

core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/EditorUtility.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@
9797
import org.eclipse.ui.IEditorPart;
9898
import org.eclipse.ui.IEditorRegistry;
9999
import org.eclipse.ui.IFileEditorInput;
100+
import org.eclipse.ui.IURIEditorInput;
100101
import org.eclipse.ui.IWorkbench;
101102
import org.eclipse.ui.IWorkbenchPage;
102103
import org.eclipse.ui.IWorkbenchWindow;
@@ -676,8 +677,20 @@ public static String getEditorID(IEditorInput input, Object inputObject) {
676677
contentType = Platform.getContentTypeManager().getContentType(CCorePlugin.CONTENT_TYPE_BINARYFILE);
677678
}
678679
}
679-
IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry();
680-
IEditorDescriptor desc = registry.getDefaultEditor(input.getName(), contentType);
680+
IEditorDescriptor desc = null;
681+
if (input instanceof IURIEditorInput uriEditorInput) {
682+
try {
683+
IFileStore fileStore = EFS.getStore(uriEditorInput.getURI());
684+
// get editor by considering overridden default editor association via IEditorAssociationOverride:
685+
desc = IDE.getEditorDescriptorForFileStore(fileStore, false);
686+
} catch (CoreException e) {
687+
CUIPlugin.log(e);
688+
}
689+
}
690+
if (desc == null) {
691+
IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry();
692+
desc = registry.getDefaultEditor(input.getName(), contentType);
693+
}
681694
if (desc != null) {
682695
String editorID = desc.getId();
683696
if (input instanceof IFileEditorInput) {

0 commit comments

Comments
 (0)