bug-classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug swing/26888] JTextArea/PlainDocument - removing text with line-brea


From: thebohemian at gmx dot net
Subject: [Bug swing/26888] JTextArea/PlainDocument - removing text with line-breaks makes component unusable
Date: 29 Mar 2006 14:24:18 -0000


------- Comment #2 from thebohemian at gmx dot net  2006-03-29 14:24 -------
The last message is bogus. The problem which was observed with a slightly
tweaked version of PlainDocument and that tweak introduced the problem.

----

I found out that the problem is caused by a strange behavior of the GapContent
class. Consider GapContent is in the following state:

gapStart: 0
gapEnd: 1
Position object at b: mark = 2
<..>bc

Now if a single character ('z') is inserted. The GapContent turns into this
state:
gapStart: 1
gapEnd: 1
Position object at b: mark = 2
z<.>bc

Since the gap became smaller (gapEnd - gapStart is 0) the offset of the
position object changes from 0 to 1. If such an Position object marks the
beginning of the first Element in a PlainDocument that is wrong. The offset
should not change.

The fix for this problem is to add a call to resetMarksAtZero() after copying
the new characters into the buffer of GapContent (in replace()).

The code will look like this afterards:

...

if (addItems != null)
      {
        System.arraycopy(addItems, 0, buffer, gapStart, addSize);
        resetMarksAtZero();
        gapStart += addSize;
      }

...


-- 

thebohemian at gmx dot net changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2006-03-27 22:31:46         |2006-03-29 14:24:17
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26888





reply via email to

[Prev in Thread] Current Thread [Next in Thread]