Bug 497919

Summary: org.eclipse.search.internal.ui.text.EditorOpener:openAndSelect should check all editors for an internal one
Product: [Eclipse Project] Platform Reporter: Charles Tian <ctian>
Component: TextAssignee: Platform-Text-Inbox <platform-text-inbox>
Status: NEW --- QA Contact:
Severity: enhancement    
Priority: P3 CC: rheydenr
Version: 4.5.2   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:

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.