lkishalmi closed pull request #1012: [NETBEANS-1440] Fixed BadLocationException 
on triple click to select …
URL: https://github.com/apache/incubator-netbeans/pull/1012
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/ide/editor.document/src/org/netbeans/modules/editor/document/TextSearchUtils.java
 
b/ide/editor.document/src/org/netbeans/modules/editor/document/TextSearchUtils.java
index 30ad0dd2b8..8e57d2f96b 100644
--- 
a/ide/editor.document/src/org/netbeans/modules/editor/document/TextSearchUtils.java
+++ 
b/ide/editor.document/src/org/netbeans/modules/editor/document/TextSearchUtils.java
@@ -93,8 +93,8 @@ public static int getWordEnd(@NonNull CharSequence text, 
@NonNull CharClassifier
         for (int i = offset; i < limitOffset; i++) {
             char ch = text.charAt(i);
             if (ch == '\n') {
-                // If first char skip right above it
-                return (i == offset) ? i + 1 : i;
+                // If first char and offset is not at EOF skip right above it
+                return (i == offset && i + 1 < limitOffset) ? i + 1 : i;
             }
             if (classifier.isWhitespace(ch)) {
                 if (inIdentifier) { // End of identifier
diff --git 
a/ide/editor.document/test/unit/src/org/netbeans/modules/editor/document/TextSearchUtilsTest.java
 
b/ide/editor.document/test/unit/src/org/netbeans/modules/editor/document/TextSearchUtilsTest.java
index a21c431334..94c8c32536 100644
--- 
a/ide/editor.document/test/unit/src/org/netbeans/modules/editor/document/TextSearchUtilsTest.java
+++ 
b/ide/editor.document/test/unit/src/org/netbeans/modules/editor/document/TextSearchUtilsTest.java
@@ -40,6 +40,7 @@ public TextSearchUtilsTest() {
     //                                             01234 567890123 4567890
     private static final String MULTI_LINE_TEXT = " ab \n/** jdoc\n * 2nd";
     
+    private static final String MULTI_LINE_TEXT1 = "Hello\nWorld\n";
     /**
      * Test of getWordStart method, of class TextSearchUtils.
      */
@@ -62,6 +63,10 @@ public void testGetWordEnd() {
 
         assertEquals(13, TextSearchUtils.getWordEnd(INT_I_TEXT, DC, 10));
         assertEquals(10, TextSearchUtils.getWordEnd(INT_I_TEXT, DC, 8));
+
+        assertEquals(11, TextSearchUtils.getWordEnd(MULTI_LINE_TEXT1, DC, 11));
+        assertEquals(6, TextSearchUtils.getWordEnd(MULTI_LINE_TEXT1, DC, 5));
+        assertEquals(5, TextSearchUtils.getWordEnd(MULTI_LINE_TEXT1, DC, 4));
     }
 
     /**


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to