Index: javax/swing/text/GapContent.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/swing/text/GapContent.java,v retrieving revision 1.32 diff -u -r1.32 GapContent.java --- javax/swing/text/GapContent.java 11 Oct 2005 20:14:22 -0000 1.32 +++ javax/swing/text/GapContent.java 23 Nov 2005 12:01:20 -0000 @@ -100,15 +100,15 @@ public int compareTo(Object o) { if (o instanceof Integer) - { - int otherMark = ((Integer) o).intValue(); - return mark - otherMark; - } + { + int otherMark = ((Integer) o).intValue(); + return mark - otherMark; + } else - { - GapContentPosition other = (GapContentPosition) o; - return mark - other.mark; - } + { + GapContentPosition other = (GapContentPosition) o; + return mark - other.mark; + } } /** @@ -644,6 +644,13 @@ new GapContentPosition(offset)); if (index1 < 0) index1 = -(index1 + 1); + + // Search the first index with the specified offset. The binarySearch does + // not necessarily find the first one. + while (index1 > 0 + && ((GapContentPosition) positions.get(index1 - 1)).mark == offset) + index1--; + for (ListIterator i = positions.listIterator(index1); i.hasNext();) { GapContentPosition p = (GapContentPosition) i.next(); @@ -672,6 +679,13 @@ new GapContentPosition(offset)); if (index1 < 0) index1 = -(index1 + 1); + + // Search the first index with the specified offset. The binarySearch does + // not necessarily find the first one. + while (index1 > 0 + && ((GapContentPosition) positions.get(index1 - 1)).mark == offset) + index1--; + for (ListIterator i = positions.listIterator(index1); i.hasNext();) { GapContentPosition p = (GapContentPosition) i.next(); @@ -700,6 +714,12 @@ new GapContentPosition(offset)); if (index1 < 0) index1 = -(index1 + 1); + + // Search the first index with the specified offset. The binarySearch does + // not necessarily find the first one. + while (index1 > 0 + && ((GapContentPosition) positions.get(index1 - 1)).mark == offset) + index1--; for (ListIterator i = positions.listIterator(index1); i.hasNext();) { GapContentPosition p = (GapContentPosition) i.next();