Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 261046

Summary: [implementation] Abstract text editor incorrectly clears restored selection position
Product: [Eclipse Project] Platform Reporter: Oleg Besedin <ob1.eclipse>
Component: TextAssignee: Platform-Text-Inbox <platform-text-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert
Version: 3.5   
Target Milestone: 3.5 M5   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Bug Depends on:    
Bug Blocks: 188380    
Attachments:
Description Flags
Proposed patch none

Description Oleg Besedin CLA 2009-01-14 12:05:05 EST
Created attachment 122550 [details]
Proposed patch

The AbstractTextEditor seems to have code that clears selection position in restart if it first called for a different part:

public void partOpened(IWorkbenchPart part) {
	// Restore the saved state if any
	if (part == AbstractTextEditor.this && fMementoToRestore != null && containsSavedState(fMementoToRestore))
		doRestoreState(fMementoToRestore);
	fMementoToRestore= null;
}

Note that fMementoToRestore will be cleared regardless of where it was used or not.

As a result, restored selection gets lost even if code is modified to store it (see bug 188380).
Comment 1 Dani Megert CLA 2009-01-15 11:38:30 EST
Thanks for the patch - it makes sense.
Committed to HEAD.
Available in builds > N20090114-2000.