Bug 25034

Summary: Loosing last used editor as default editor
Product: [Eclipse Project] Platform Reporter: Richard Kulp <richkulp>
Component: UIAssignee: Platform-UI-Inbox <Platform-UI-Inbox>
Status: RESOLVED DUPLICATE QA Contact:
Severity: normal    
Priority: P3    
Version: 2.0   
Target Milestone: ---   
Hardware: PC   
OS: Windows 2000   
Whiteboard:

Description Richard Kulp CLA 2002-10-17 17:41:24 EDT
There is a bug in that if you open a file that has more than one type of editor 
assigned to it using a specific editor. If you do the following this is the bug:

1) Using OpenWith-> a specific editor that is not the default editor
2) Close the editor
 (now this specific editor is marked as the default editor)
3) Using OpenWith-> select that specific editor again
 (now this specific editor is no longer marked as the default editor)

Double-clicking always opens the default editor without changing who the next 
default editor will be.

The problem is in:

EditorManager.openEditor(String editorId,IEditorInput input,boolean setVisible)

It is in this piece of code:

// Update the default editor for this file.
IEditorDescriptor defaultDesc = (EditorDescriptor)getEditorRegistry
().getDefaultEditor(file);
if (defaultDesc == null)
  defaultDesc = (EditorDescriptor)getEditorRegistry().getDefaultEditor();
String editorID = desc.getId();
if(defaultDesc.getId().equals(editorId)) {
  getEditorRegistry().setDefaultEditor(file, null);
} else {
  getEditorRegistry().setDefaultEditor(file, editorID);
}

In this case getDefaultEditor(file) will return the current selected editor as 
the default editor (since we choose that one specifically) and so it will match 
the current selected editor and so do a setDefaultEditor(file, null); Which 
then wipes out this specific selected editor as the default and returns it to 
the filetype default editor, which is a different editor. The problem is that 
it is not the default editor that is wanted for this test, but the default 
default editor (i.e. the default editor for the file type, not the default 
editor for the file itself). In that case if you specifically selected the 
default default (filetype editor) you want to wipe out the selection.

Thanks,
Rich Kulp
Comment 1 Sonia Dimitrov CLA 2002-10-18 09:26:03 EDT

*** This bug has been marked as a duplicate of 24684 ***