This is an automated email from the ASF dual-hosted git repository.

lkishalmi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-netbeans.git


The following commit(s) were added to refs/heads/master by this push:
     new 636aacc  [NETBEANS-1440] Fixed BadLocationException on double click to 
select text at EOF
636aacc is described below

commit 636aacc333fcd6b90813e8d42431474dcbce404d
Author: arusinha <arunava.si...@oracle.com>
AuthorDate: Wed Nov 7 11:53:55 2018 +0530

    [NETBEANS-1440] Fixed BadLocationException on double click to select text 
at EOF
---
 .../src/org/netbeans/modules/editor/document/TextSearchUtils.java    | 4 ++--
 .../org/netbeans/modules/editor/document/TextSearchUtilsTest.java    | 5 +++++
 2 files changed, 7 insertions(+), 2 deletions(-)

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 30ad0dd..8e57d2f 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 class TextSearchUtils {
         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 a21c431..94c8c32 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 class 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 class TextSearchUtilsTest {
 
         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));
     }
 
     /**


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@netbeans.apache.org
For additional commands, e-mail: commits-h...@netbeans.apache.org

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

Reply via email to