mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-03 22:35:43 +02:00
Fix for 217727: Binary files do not open in the binary editor
This commit is contained in:
parent
7e9700c5a7
commit
76bea72bfb
1 changed files with 13 additions and 1 deletions
|
@ -513,10 +513,22 @@ public class EditorUtility {
|
||||||
}
|
}
|
||||||
contentType= CCorePlugin.getContentType(project, input.getName());
|
contentType= CCorePlugin.getContentType(project, input.getName());
|
||||||
}
|
}
|
||||||
|
// handle binary files without content-type (e.g. executables without extension)
|
||||||
|
if (contentType == null && cElement != null) {
|
||||||
|
final int elementType= cElement.getElementType();
|
||||||
|
if (elementType == ICElement.C_ARCHIVE || elementType == ICElement.C_BINARY) {
|
||||||
|
contentType= Platform.getContentTypeManager().getContentType(CCorePlugin.CONTENT_TYPE_BINARYFILE);
|
||||||
|
}
|
||||||
|
}
|
||||||
IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry();
|
IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry();
|
||||||
IEditorDescriptor desc= registry.getDefaultEditor(input.getName(), contentType);
|
IEditorDescriptor desc= registry.getDefaultEditor(input.getName(), contentType);
|
||||||
if (desc != null) {
|
if (desc != null) {
|
||||||
return desc.getId();
|
String editorID= desc.getId();
|
||||||
|
if (input instanceof IFileEditorInput) {
|
||||||
|
IFile file= ((IFileEditorInput)input).getFile();
|
||||||
|
IDE.setDefaultEditor(file, editorID);
|
||||||
|
}
|
||||||
|
return editorID;
|
||||||
}
|
}
|
||||||
|
|
||||||
return DEFAULT_TEXT_EDITOR_ID;
|
return DEFAULT_TEXT_EDITOR_ID;
|
||||||
|
|
Loading…
Add table
Reference in a new issue