Bug 193368 - BadLocationException thrown when deleting characters at end of Document
Summary: BadLocationException thrown when deleting characters at end of Document
Status: RESOLVED INVALID
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-Text-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: needinfo
Depends on:
Blocks:
 
Reported: 2007-06-19 13:18 EDT by Keith McQueen CLA
Modified: 2007-06-22 10:04 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Keith McQueen CLA 2007-06-19 13:18:51 EDT
Build ID: M20070212-1330

In our custom text editor (subclass of org.eclipse.ui.editors.text.TextEditor) when I delete characters at the very end of the document (also a custom document, but a subclass of org.eclipse.jface.text.Document) a BadLocationException exception is thrown at org.eclipse.jface.text.AbstractDocument line 1295 (computePartitioning method).  The BadLocationException is thrown because the offset + length is greater than the document's length.  The thing is, that the values for the offset and length came from a DirtyRegion created by the org.eclipse.jface.text.reconciler.AbstractReconciler#createDirtyRegion() method (line 515).  It seems that the two are not compatible.  The exception is caught gracefully enough (in org.eclipse.jface.text.reconciler.Reconciler#computePartitioning, line 215) to return an empty array of TypedRegions, but unfortunately it breaks some functionality in our editor.  We need the reconciler to reconcile the change.

Now the other thing that is weird to me, is that we have a custom partitioner for our editor, and it returns a region from the documentChanged2() method, but that region does not seem to be used by anyone (it gets returned to the AbstractDocument#updateDocumentStructures() method where it is assigned to an instance variable, from there it is accessed in the AbstractDocument#doFireDocumentChanged(DocumentEvent) method, passed to the AbstractDocument#doFireDocumentChanged(DocumentEvent, boolean, IRegion) method only to be discarded/ignored).

So, to make a long story a little longer, no reconciliation seems to happen when deletions are made at the end of a document.
Comment 1 Dani Megert CLA 2007-06-19 15:04:15 EDT
We use all those classes together in the Java editor with no problems. Please either submit a test case or an example plug-in that shows the problem and then let's us verify the fix. No work planned until we have that.

Also, please check whether it works using 3.3 RC4.
Comment 2 Dani Megert CLA 2007-06-22 09:59:41 EDT
Get rid of deprecated state.
Comment 3 Dani Megert CLA 2007-06-22 10:04:51 EDT
.