Author: rwhitcomb
Date: Fri Jul 18 22:49:26 2014
New Revision: 1611829

URL: http://svn.apache.org/r1611829
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.

Modified:
    pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkin.java

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkin.java
URL: 
http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkin.java?rev=1611829&r1=1611828&r2=1611829&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkin.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkin.java Fri Jul 18 
22:49:26 2014
@@ -966,11 +966,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