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

Bug 165298

Summary: [projection] ProjectionMapping.toImageLine is wrong for projections at the end of the document
Product: [Eclipse Project] Platform Reporter: Anton Leherbauer <aleherb+eclipse>
Component: TextAssignee: Platform-Text-Inbox <platform-text-inbox>
Status: CLOSED INVALID QA Contact:
Severity: minor    
Priority: P3    
Version: 3.2   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Adding test9c to ProjectionMappingTest none

Description Anton Leherbauer CLA 2006-11-21 06:46:36 EST
When a projection covers the last line of a document, then ProjectionMapping.toImageLine will return a wrong line number for the master document line immediately following the projection fragment.

Example:

0 /*
1  * this comment is folded
2  * this line causes trouble
3  */

folded into

0  * this comment is folded

ProjectionMapping.toImageLine(0) == -1 // OK
ProjectionMapping.toImageLine(1) == 0  // OK
ProjectionMapping.toImageLine(2) == 1  // not OK, should be -1
ProjectionMapping.toImageLine(3) == -1 // OK
Comment 1 Anton Leherbauer CLA 2006-11-21 06:51:02 EST
Created attachment 54254 [details]
Adding test9c to ProjectionMappingTest

Patch against current HEAD (20061121).
Comment 2 Dani Megert CLA 2006-11-23 09:39:00 EST
The original offset that directly follows the last fragment is counted to said fragment. Changing this would break all existing code.

Do you have an example where the current code gives trouble?
Comment 3 Anton Leherbauer CLA 2006-11-23 10:09:32 EST
The WhitespaceCharacterPainter checks for folded lines by testing whether the next model line is mapped to -1. This works for all projections, but those that cover the last line of the document.
In the Java editor it is practically impossible (I think) to create a folding at the end, because top-level classes are not foldable and comments afterwards are'nt either.

In the CDT editor such projections are possible and in this case the whitespace painter considers the line as not folded. 
Comment 4 Dani Megert CLA 2006-11-23 10:20:29 EST
If you find a patch that doesn't break the current assumptions I'm happy to accept it ;-)
Comment 5 Anton Leherbauer CLA 2010-03-08 08:16:55 EST
I am withdrawing this bug because ProjectionMapping does not have the necessary information to make the decision whether a projection represents the end of the (master-)document or not.  See also bug 301023.