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

Bug 132445

Summary: [misc] marker position selection not synchronised
Product: [Eclipse Project] Platform Reporter: David <fredgroup>
Component: TextAssignee: Platform-Text-Inbox <platform-text-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: minor    
Priority: P3    
Version: 3.1.1   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard: stalebug

Description David CLA 2006-03-18 04:32:38 EST
Selecting a task from the Task view shows the task in the editor with the task text selected.

If you add text in the editor above, below or within the task text then the selection is still correct when going there from the task view. This is also true when you save the text file.

However if you add text in the editor above, below or within the task text AND do not save the file AND then from the task view modify the "task description" or change the "DONE" status then selection in the editor uses the old selection stored in the marker and NOT the selection from the annotation model.
Comment 1 Dani Megert CLA 2006-03-20 07:13:32 EST
Fixed in HEAD.
Available in builds > N20060320-0010.
Comment 2 David CLA 2006-03-29 06:40:55 EST
(In reply to comment #1)
> Fixed in HEAD.
> Available in builds > N20060320-0010.
> 
I haven't tested version N20060320-0010 however I have downloaded the windows zip file and looked at the source code.
The problem of selecting the text when you click on the Annotation in the ruler is still there. 

See org.eclipse.ui.texteditor.SelectMarkerRulerAction.run().  At the end of this function it still has
     // Select and reveal in editor
	int offset= MarkerUtilities.getCharStart(marker);
	int endOffset= MarkerUtilities.getCharEnd(marker);
	if (offset > -1 && endOffset > -1)
		fTextEditor.selectAndReveal(offset, endOffset - offset);


i.e. It is NOT using the AnnotationModel  position.

Interestingly the TaskMarker Annotation selects different text depending if you have opened up the TaskViewer or not.

I DO NOT like the "Hard coding" of if(problemMarker) or if(TaskMarker).  I find code like this hard to use for my own "MyMarker". i.e. It behaves differently if it has TaskMarker as super or not.  And this is with the AnnotationRuler code which I have no access to modify.
Comment 3 Dani Megert CLA 2006-03-29 07:58:02 EST
What I've fixed is that the editor shows the new text in the hover. I misinterpreted the bug and did not touch SelectMarkerRulerAction.

And of course you're right with "hard-coding" the marker type but that was needed up to now. I can now use MarkerViewUtil to fix this.

Released to HEAD and will show up at latest in I20060329-1600.
Comment 4 David CLA 2006-03-29 08:24:50 EST
(In reply to comment #3)
> What I've fixed is that the editor shows the new text in the hover. I
> misinterpreted the bug and did not touch SelectMarkerRulerAction.
> 
> And of course you're right with "hard-coding" the marker type but that was
> needed up to now. I can now use MarkerViewUtil to fix this.
> 
> Released to HEAD and will show up at latest in I20060329-1600.
> 

Good.

The SelectMarkerRulerAction is used for the editor of files with *.java or *.txt
BUT not for the *.cpp.  The editor for *.cpp doesn't highlight any selected text. 
Comment 5 Dani Megert CLA 2006-03-29 08:29:44 EST
You can file a bug against CDT: they have to register the action in their plugin.xml.
Comment 6 Dani Megert CLA 2006-03-30 03:20:44 EST
Verified in I20060330-0010 in Java and Text editor with bookmarks and tasks.
Comment 7 Dani Megert CLA 2006-05-17 10:13:48 EDT
The code change which fixed the problem described in comment 0 had to be pulled out again because it caused bug 142170.

All other changes discussed in comment 2 and onwards are still in.
Comment 8 Dani Megert CLA 2006-05-17 10:14:37 EDT
Note that the behavior reported in comment 0 is in since 1.0.
Comment 9 Lars Vogel CLA 2019-09-04 03:06:35 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it and remove the stalebug whiteboard tag. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

-