Hi,
while working on the new paint algorithm for the
DefaultHighlighter.DefaultHighlighterPainter (which is mostly copy and pasted
code from BasicTextUI.damageRange) I saw some thinkos in my first 
implementation.

This fixes that.

2006-03-06  Robert Schuster  <[EMAIL PROTECTED]>

        * javax/swing/plaf/basic/BasicTextUI.java:
        (damageRange): Rewritten if-expressions to correctly identify the
        break condition.

cya
Robert
Index: javax/swing/plaf/basic/BasicTextUI.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicTextUI.java,v
retrieving revision 1.72
diff -u -r1.72 BasicTextUI.java
--- javax/swing/plaf/basic/BasicTextUI.java	3 Mar 2006 11:06:11 -0000	1.72
+++ javax/swing/plaf/basic/BasicTextUI.java	6 Mar 2006 02:25:37 -0000
@@ -1023,7 +1023,11 @@
             // we should stop searching for one.
             
             int posBelow = Utilities.getPositionBelow(t, p0, l1.x);
-            if (posBelow < p1 && posBelow != -1 && posBelow != p0)
+            int p1RowStart = Utilities.getRowStart(t, p1);
+            
+            if (posBelow != -1
+                && posBelow != p0
+                && Utilities.getRowStart(t, posBelow) != p1RowStart)
               {
                 // Take the rectangle of the offset we just found and grow it
                 // to the maximum width. Retain y because this is our start
@@ -1034,10 +1038,15 @@
                 
                 // Find further lines which have to be damaged completely.
                 int nextPosBelow = posBelow;
-                while (nextPosBelow < p1 && nextPosBelow != -1 && posBelow != nextPosBelow)
+                while (nextPosBelow != -1
+                       && posBelow != nextPosBelow
+                       && Utilities.getRowStart(t, nextPosBelow) != p1RowStart)
                   {
                     posBelow = nextPosBelow;
                     nextPosBelow = Utilities.getPositionBelow(t, posBelow, l1.x);
+                    
+                    if (posBelow == nextPosBelow)
+                      break;
                   }
                 // Now posBelow is an offset on the last line which has to be damaged
                 // completely. (newPosBelow is on the same line as p1)

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to