Hi, although this patch is ridicously simple I ask for what others think about it. I too pen & paper to simulate what should happen in shiftGapEndUp and came to the conclusion that there is no reason why the mark should be set to newGapEnd + 1 and that the correct new mark would have been newGapEnd.
Here is my example:
< - gap start
> - gap end
This is the starting situation. You can reach this by inserting "abc\ndef\n" at
position 0 in an empty array and then moving the gap down to 4 (= shiftGap(4) ).
a b c . <d e> d e f .
0 1 2 3 4 5 6 7 8 9 10
Now, finish the removal of the 'd' by calling shiftGapEndUp(7). The result
should be:
a b c . <d e d> e f .
0 1 2 3 4 5 6 7 8 9 10
Obviously a Position that pointed to the 'd' (mark = 6) should now point to the
'e' at mark 7 and not 8 what classpath does without this patch.
I mauve test that supports my argument was already added. It is the last case in
gnu.testlet.javax.swing.text.GapContent.remove.testGeneral. Ah, yes. There are
no regression with this patch.
This little number game looks harmless but the effect in a JTextArea is quite
funny. What is even more funny was tracing this down to the actual problem ...
;)
Unfortunately with this patch not all of single character removal problems in
the JTextArea are solved. I will inspect this after wake up.
2006-02-20 Robert Schuster <[EMAIL PROTECTED]>
* javax/swing/text/GapContent.java:
(shiftGapEndUp): Corrected new mark value.
cya
Robert
Index: javax/swing/text/GapContent.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/text/GapContent.java,v
retrieving revision 1.36
diff -u -r1.36 GapContent.java
--- javax/swing/text/GapContent.java 10 Feb 2006 14:24:03 -0000 1.36
+++ javax/swing/text/GapContent.java 20 Feb 2006 01:13:48 -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
