Skip to content

Commit

Permalink
[eclipse-cdt#808] Support overriden default-editor-association in Edi…
Browse files Browse the repository at this point in the history
…torUtility (eclipse-cdt#809)
  • Loading branch information
ghentschke authored May 31, 2024
1 parent d8328fb commit 9f85daf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.cdt.ui; singleton:=true
Bundle-Version: 8.1.400.qualifier
Bundle-Version: 8.1.500.qualifier
Bundle-Activator: org.eclipse.cdt.ui.CUIPlugin
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IEditorRegistry;
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.IURIEditorInput;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
Expand Down Expand Up @@ -676,8 +677,20 @@ public static String getEditorID(IEditorInput input, Object inputObject) {
contentType = Platform.getContentTypeManager().getContentType(CCorePlugin.CONTENT_TYPE_BINARYFILE);
}
}
IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry();
IEditorDescriptor desc = registry.getDefaultEditor(input.getName(), contentType);
IEditorDescriptor desc = null;
if (input instanceof IURIEditorInput uriEditorInput) {
try {
IFileStore fileStore = EFS.getStore(uriEditorInput.getURI());
// get editor by considering overridden default editor association via IEditorAssociationOverride:
desc = IDE.getEditorDescriptorForFileStore(fileStore, false);
} catch (CoreException e) {
CUIPlugin.log(e);
}
}
if (desc == null) {
IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry();
desc = registry.getDefaultEditor(input.getName(), contentType);
}
if (desc != null) {
String editorID = desc.getId();
if (input instanceof IFileEditorInput) {
Expand Down

0 comments on commit 9f85daf

Please sign in to comment.