You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by gb...@apache.org on 2010/03/30 15:28:38 UTC
svn commit: r929129 -
/pivot/trunk/wtk/src/org/apache/pivot/wtk/text/Element.java
Author: gbrown
Date: Tue Mar 30 13:28:38 2010
New Revision: 929129
URL: http://svn.apache.org/viewvc?rev=929129&view=rev
Log:
Fix minor bug that caused IndexOutOfBounds exception in TextArea.
Modified:
pivot/trunk/wtk/src/org/apache/pivot/wtk/text/Element.java
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/text/Element.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/text/Element.java?rev=929129&r1=929128&r2=929129&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/text/Element.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/text/Element.java Tue Mar 30 13:28:38 2010
@@ -448,21 +448,14 @@ public abstract class Element extends No
throw new IndexOutOfBoundsException();
}
- int index = -1;
-
- for (int i = 0, n = nodes.getLength(); i < n; i++) {
- Node node = nodes.get(i);
- int nodeOffset = node.getOffset();
- int characterCount = node.getCharacterCount();
-
- if (offset >= nodeOffset
- && offset < nodeOffset + characterCount) {
- index = i;
- break;
- }
+ int i = 0;
+ int n = nodes.getLength();
+ while (i < n
+ && offset >= nodes.get(i).getOffset()) {
+ i++;
}
- return index;
+ return i - 1;
}
/**