diff --git a/src/main/java/org/javacs/FindNameAt.java b/src/main/java/org/javacs/FindNameAt.java index 0cc4951b..429da8d3 100644 --- a/src/main/java/org/javacs/FindNameAt.java +++ b/src/main/java/org/javacs/FindNameAt.java @@ -99,6 +99,6 @@ private boolean contains(Tree t, CharSequence name, long find) { start = FindHelper.findNameIn(root, name, start, end); end = start + name.length(); if (start == -1 || end == -1) return false; - return start <= find && find < end; + return start <= find && find <= end; } } diff --git a/src/test/java/org/javacs/GotoTest.java b/src/test/java/org/javacs/GotoTest.java index ee28179f..e45a9d76 100644 --- a/src/test/java/org/javacs/GotoTest.java +++ b/src/test/java/org/javacs/GotoTest.java @@ -75,6 +75,14 @@ public void methodReference() { assertThat(suggestions, hasItem("Goto.java:41")); } + @Test + public void wordBoundary() { + for (var column = 9; column <= 14; column++) { + var suggestions = doGoto(file, 10, column); + assertThat(suggestions, hasItem("Goto.java:5")); + } + } + @Test public void otherStaticMethod() { var suggestions = doGoto(file, 29, 25);