Bug 497919 - org.eclipse.search.internal.ui.text.EditorOpener:openAndSelect should check all editors for an internal one
Summary: org.eclipse.search.internal.ui.text.EditorOpener:openAndSelect should check a...
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 4.5.2   Edit
Hardware: PC Windows 7
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Platform-Text-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-07-14 11:45 EDT by Charles Tian CLA
Modified: 2020-01-19 09:09 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Charles Tian CLA 2016-07-14 11:45:34 EDT
With the current implementation, if the user sets a launcher as default for opening a specific file type, searches for files of that type will open in the default plain text editor. However, the user could have another internal editor installed for that file type, just not set as default. In this situation, I believe that Eclipse should still use the internal editor over the default one. 

I propose the following fix: if the default editor is found to be null or external, look for in the editor registry for an internal editor, and only fall back on the default editor if one was also not found in the editor registry. Something roughly like this:

	public IEditorPart openAndSelect(IWorkbenchPage wbPage, IFile file, int offset, int length, boolean activate) throws PartInitException {
		System.out.println("open and select");
		String editorId= null;
		IEditorDescriptor desc= IDE.getEditorDescriptor(file);
		if (desc == null || !desc.isInternal()) {
			IEditorRegistry editorReg = PlatformUI.getWorkbench().getEditorRegistry();
			for(IEditorDescriptor d : editorReg.getEditors(file.getName())) {
				if(d.isInternal()) {
					editorId= d.getId();
					break;
				}
			}
			if(editorId == null) {
				editorId= "org.eclipse.ui.DefaultTextEditor"; //$NON-NLS-1$
			}
		} else {
			editorId= desc.getId();
		}
		...
Comment 1 Ralf Heydenreich CLA 2020-01-19 09:09:52 EST
This bug seems to be obsolete. I've tested it with QuickSearch dialog and File Search dialog and I could open the files with their correct internal editor. So I assume the bug can be closed.