diff --git a/platform/platform-tests/testSrc/com/intellij/psi/util/NameUtilMatchingTest.java b/platform/platform-tests/testSrc/com/intellij/psi/util/NameUtilMatchingTest.java index 1ae12d2e69c3..eaa11895751b 100644 --- a/platform/platform-tests/testSrc/com/intellij/psi/util/NameUtilMatchingTest.java +++ b/platform/platform-tests/testSrc/com/intellij/psi/util/NameUtilMatchingTest.java @@ -412,6 +412,7 @@ public class NameUtilMatchingTest extends TestCase { assertDoesntMatch("Foo ", "Foox"); assertDoesntMatch("Collections ", "CollectionSplitter"); assertMatches("CollectionS ", "CollectionSplitter"); + assertMatches("*run ", "in Runnable.run"); assertDoesntMatch("*l ", "AppDelegate"); assertDoesntMatch("*le ", "AppDelegate"); diff --git a/platform/util/src/com/intellij/psi/codeStyle/MinusculeMatcher.java b/platform/util/src/com/intellij/psi/codeStyle/MinusculeMatcher.java index 040fd2c39b7e..db0e784927b7 100644 --- a/platform/util/src/com/intellij/psi/codeStyle/MinusculeMatcher.java +++ b/platform/util/src/com/intellij/psi/codeStyle/MinusculeMatcher.java @@ -281,9 +281,8 @@ public class MinusculeMatcher implements Matcher { } while (isWildcard(patternIndex)); if (patternIndex == myPattern.length) { - boolean space = isPatternChar(patternIndex - 1, ' '); // the trailing space should match if the pattern ends with the last word part, or only its first hump character - if (space && nameIndex != name.length() && (patternIndex < 2 || !isUpperCaseOrDigit(myPattern[patternIndex - 2]))) { + if (isTrailingSpacePattern() && nameIndex != name.length() && (patternIndex < 2 || !isUpperCaseOrDigit(myPattern[patternIndex - 2]))) { int spaceIndex = name.indexOf(' ', nameIndex); if (spaceIndex >= 0) { return FList.emptyList().prepend(TextRange.from(spaceIndex, 1)); @@ -301,6 +300,10 @@ public class MinusculeMatcher implements Matcher { return matchSkippingWords(name, patternIndex, nameIndex, true, isAsciiName); } + private boolean isTrailingSpacePattern() { + return isPatternChar(myPattern.length - 1, ' '); + } + private static boolean isUpperCaseOrDigit(char p) { return Character.isUpperCase(p) || Character.isDigit(p); } @@ -328,7 +331,7 @@ public class MinusculeMatcher implements Matcher { // match the remaining pattern only if we haven't already seen fragment of the same (or bigger) length // because otherwise it means that we already tried to match remaining pattern letters after it with the remaining name and failed // but now we have the same remaining pattern letters and even less remaining name letters, and so will fail as well - if (fragmentLength > maxFoundLength) { + if (fragmentLength > maxFoundLength || nameIndex + fragmentLength == name.length() && isTrailingSpacePattern()) { if (!isMiddleMatch(name, patternIndex, nameIndex)) { maxFoundLength = fragmentLength; }