The attached patch file was empty. Here is the correct one. cya Robert
Robert Schuster wrote: > Hi, > this patch contains my already approved fix for GapContent and another small > change that fixes the remaining issue I was seeing. > > While the GapContent fix makes it possible to remove the 'd' in this document > correctly: > > abc > def > > The change of the order of operations in AbstractDocument.remove makes it > possible to remove the 'c' from the same document. > > What was wrong before the patch is that the content was already changed when > PlainDocument.removeUpdate is invoked. In the example above that method calls > getElementIndex() for offset 3 which was initially on the first line but since > the content is already modified it returns that offset 3 is on the second > line. > This in turn leads the algorithm to the assumption that a line-spanning > removal > has taken place and that the Elements representing these lines have to be > joined. > > Both defects lead to the problems mentioned in PR 26354 which are now solved. > > The patch was approved by Roman on IRC. > > 2006-02-20 Robert Schuster <[EMAIL PROTECTED]> > > * javax/swing/text/GapContent.java: > (shiftGapEndUp): Corrected new mark value. > * javax/swing/text/AbstractDocument.java: > (remove): Changed order of operations. > > cya > Robert >
Index: javax/swing/text/AbstractDocument.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/text/AbstractDocument.java,v
retrieving revision 1.49
diff -u -r1.49 AbstractDocument.java
--- javax/swing/text/AbstractDocument.java 20 Feb 2006 12:02:33 -0000 1.49
+++ javax/swing/text/AbstractDocument.java 20 Feb 2006 12:05:47 -0000
@@ -690,8 +690,11 @@
try
{
writeLock();
- UndoableEdit temp = content.remove(offset, length);
+
+ // The order of the operations below is critical!
removeUpdate(event);
+ UndoableEdit temp = content.remove(offset, length);
+
postRemoveUpdate(event);
fireRemoveUpdate(event);
}
Index: javax/swing/text/GapContent.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/text/GapContent.java,v
retrieving revision 1.38
diff -u -r1.38 GapContent.java
--- javax/swing/text/GapContent.java 20 Feb 2006 12:02:33 -0000 1.38
+++ javax/swing/text/GapContent.java 20 Feb 2006 12:05:47 -0000
@@ -557,7 +557,7 @@
assert newGapEnd > gapEnd : "The new gap end must be greater than the "
+ "old gap end.";
- setPositionsInRange(gapEnd, newGapEnd - gapEnd, newGapEnd + 1);
+ setPositionsInRange(gapEnd, newGapEnd - gapEnd, newGapEnd);
gapEnd = newGapEnd;
}
signature.asc
Description: OpenPGP digital signature
