Author: rwhitcomb
Date: Fri Jul 18 22:53:02 2014
New Revision: 1611832

URL: http://svn.apache.org/r1611832
Log:
PIVOT-954: Resolve "IndexOutOfBoundsException" thrown from TextAreaSkin
when you have either an empty document or any document where the first
line has nothing (except the line ending), and you double click on the
first line (or any line in the case of an empty document).

Basically we just need to catch the "start" value being negative before
trying to get the character there.

This is a merge of revision 1611829 from trunk to branches/2.0.x.

Modified:
    pivot/branches/2.0.x/   (props changed)
    pivot/branches/2.0.x/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkin.java

Propchange: pivot/branches/2.0.x/
------------------------------------------------------------------------------
  Merged /pivot/trunk:r1611829

Modified: 
pivot/branches/2.0.x/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkin.java
URL: 
http://svn.apache.org/viewvc/pivot/branches/2.0.x/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkin.java?rev=1611832&r1=1611831&r2=1611832&view=diff
==============================================================================
--- pivot/branches/2.0.x/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkin.java 
(original)
+++ pivot/branches/2.0.x/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkin.java 
Fri Jul 18 22:53:02 2014
@@ -961,11 +961,17 @@ public class TextAreaSkin extends Compon
         int rowLength = textArea.getRowLength(start);
         if (start - rowStart >= rowLength) {
             start = rowStart + rowLength - 1;
+            if (start < 0) {
+                return;
+            }
             char ch = textArea.getCharacterAt(start);
             if (ch == '\r' || ch == '\n') {
                 start--;
             }
         }
+        if (start < 0) {
+            return;
+        }
         char ch = textArea.getCharacterAt(start);
         int selectionStart = start;
         int selectionLength = 1;


Reply via email to