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

Bug 135121

Summary: [typing] problems deleting line while in "selected element only" mode
Product: [Eclipse Project] Platform Reporter: Rafael Chaves <eclipse>
Component: TextAssignee: Tom Hofmann <eclipse>
Status: VERIFIED FIXED QA Contact:
Severity: major    
Priority: P2    
Version: 3.2   
Target Milestone: 3.2 RC1   
Hardware: All   
OS: All   
Whiteboard:

Description Rafael Chaves CLA 2006-04-05 15:37:31 EDT
M5

Having the "Show Source of Selected Element Only" option enabled, I saw two different problems when deleting lines using Ctrl-D to delete the last line of the element:

1) sometimes I get an "java.lang.IllegalArgumentException: overlaps with existing fragment"

2) otherwise, Ctrl-d will allow me to happily allow me to blindly delete lines from the elements below the one I was editing without even giving me much of a clue that I was doing that. I would expect that the editor would restrict to editing the contents of that element only.

Here is the Java source I used to reproduce the problem:

public class Test {

	/* this is a test*/
	private int var2 = 0;
	
	private int var1 = 0;
	
	public static void main(String[] args) {
		System.out.println("Hello");
	}

}

Try positioning the cursor at the end of var1 (not sure it matters) and press Ctrl-D twice.
Comment 1 Rafael Chaves CLA 2006-04-05 15:43:43 EDT
Forgot the stack trace:

!ENTRY org.eclipse.ui 4 0 2006-04-05 15:19:15.390
!MESSAGE overlaps with existing fragment
!STACK 0
java.lang.IllegalArgumentException: overlaps with existing fragment
	at org.eclipse.jface.text.projection.ProjectionDocument.internalAddMasterDocumentRange(ProjectionDocument.java:286)
	at org.eclipse.jface.text.projection.ProjectionDocument.addMasterDocumentRange(ProjectionDocument.java:559)
	at org.eclipse.jface.text.projection.ProjectionDocument.adaptProjectionToMasterChange(ProjectionDocument.java:741)
	at org.eclipse.jface.text.projection.ProjectionDocument.masterDocumentAboutToBeChanged(ProjectionDocument.java:775)
	at org.eclipse.jface.text.projection.ProjectionDocumentManager.fireDocumentEvent(ProjectionDocumentManager.java:121)
	at org.eclipse.jface.text.projection.ProjectionDocumentManager.documentAboutToBeChanged(ProjectionDocumentManager.java:138)
	at org.eclipse.jface.text.AbstractDocument.fireDocumentAboutToBeChanged(AbstractDocument.java:623)
	at org.eclipse.jface.text.AbstractDocument.replace(AbstractDocument.java:1103)
	at org.eclipse.core.internal.filebuffers.SynchronizableDocument.replace(SynchronizableDocument.java:151)
	at org.eclipse.jface.text.AbstractDocument.replace(AbstractDocument.java:1119)
	at org.eclipse.core.internal.filebuffers.SynchronizableDocument.replace(SynchronizableDocument.java:137)
	at org.eclipse.ui.texteditor.DeleteLineTarget.deleteLine(DeleteLineTarget.java:357)
	at org.eclipse.ui.texteditor.DeleteLineAction.run(DeleteLineAction.java:151)
...
Comment 2 Dani Megert CLA 2006-04-06 03:24:34 EDT
Great! We were looking for a test case for this IAE for quite some time.

See also bug 134227.
Comment 3 Tom Hofmann CLA 2006-04-07 08:29:50 EDT
Not the same as bug 134227.

This bug is caused by ProjectionDocument::internalAddMasterDocumentRange which did not account for a visible fragment of length zero.

Fixed > 20060407
Comment 4 Rafael Chaves CLA 2006-04-07 10:50:05 EDT
Tom, does this fix problem #2 as well (blindly deleting lines from the next element)? If not, is there a PR for that?
Comment 5 Tom Hofmann CLA 2006-04-07 10:51:37 EDT
(In reply to comment #4)
> Tom, does this fix problem #2 as well (blindly deleting lines from the next
> element)? If not, is there a PR for that?

2 x No - would you file a separate PR? Not sure whether we will be able to do this for 3.2, though.

Comment 6 Rafael Chaves CLA 2006-04-07 11:00:02 EDT
Ok. Opened bug 135563.
Comment 7 Benno Baumgartner CLA 2006-04-26 10:37:15 EDT
verified in 20060426