allow middle matches only with 3 typed prefix letters

This commit is contained in:
peter
2013-02-22 14:04:49 +01:00
parent e5c847486d
commit 91f97dd502
2 changed files with 10 additions and 2 deletions
@@ -256,8 +256,16 @@ public class NameUtilTest extends UsefulTestCase {
assertMatches("*f", "reformat");
assertMatches("*f", "reformatCode");
assertDoesntMatch("*fc", "reformatCode");
assertDoesntMatch("*foc", "reformatCode");
assertMatches("*forc", "reformatCode");
assertDoesntMatch("*sTC", "LazyClassTypeConstructor");
assertDoesntMatch("*Icon", "LEADING_CONSTRUCTOR");
assertMatches("*I", "LEADING_CONSTRUCTOR");
assertMatches("*i", "LEADING_CONSTRUCTOR");
assertMatches("*in", "LEADING_CONSTRUCTOR");
assertMatches("*ing", "LEADING_CONSTRUCTOR");
assertDoesntMatch("*inc", "LEADING_CONSTRUCTOR");
assertDoesntMatch("*ico", "drawLinePickedOut");
}
public void testMiddleMatchingUnderscore() {
@@ -303,10 +303,10 @@ public class MinusculeMatcher implements Matcher {
return null;
}
// middle matches have to be at least of length 2, to prevent too many irrelevant matches
// middle matches have to be at least of length 3, to prevent too many irrelevant matches
int minFragment = isPatternChar(patternIndex - 1, '*') && !isWildcard(patternIndex + 1) &&
Character.isLetterOrDigit(name.charAt(nameIndex)) && !NameUtil.isWordStart(name, nameIndex)
? 2 : 1;
? 3 : 1;
int i = 1;
boolean ignoreCase = myOptions != NameUtil.MatchingCaseSensitivity.ALL;
while (nameIndex + i < name.length() &&