mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Fix: IDEA-66363 (Plugin Dialog: speed search works incorrect if search key contains '-')
This commit is contained in:
@@ -28,19 +28,19 @@ public class PorterStemmerUtil {
|
||||
// check for zero length
|
||||
final int strLen = str.length();
|
||||
if (strLen > 0) {
|
||||
int lastDigit = -1;
|
||||
int lastNonLetter = -1;
|
||||
for (int i = 0; i < strLen; ++i) {
|
||||
char c = str.charAt(i);
|
||||
if (Character.isDigit(c)) {
|
||||
lastDigit = i;
|
||||
if (Character.isDigit(c) || c == '-' || c == '_') {
|
||||
lastNonLetter = i;
|
||||
}
|
||||
else if (!Character.isLetter(c)) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
++lastDigit;
|
||||
if (lastDigit > 0 && lastDigit < strLen) {
|
||||
return str.substring(0, lastDigit) + stemString(str.substring(lastDigit));
|
||||
++lastNonLetter;
|
||||
if (lastNonLetter > 0 && lastNonLetter < strLen) {
|
||||
return str.substring(0, lastNonLetter) + stemString(str.substring(lastNonLetter));
|
||||
}
|
||||
return stemString(str);
|
||||
}
|
||||
|
||||
@@ -447,7 +447,7 @@ public class SearchUtil {
|
||||
final String filter) {
|
||||
if (pos < end) {
|
||||
final Set<String> filters = SearchableOptionsRegistrar.getInstance().getProcessedWords(filter);
|
||||
final String[] words = text.substring(pos, end).split("[\\W&&[^_-]]");
|
||||
final String[] words = text.substring(pos, end).split("[\\W&&[^-]]+");
|
||||
for (String word : words) {
|
||||
if (filters.contains(PorterStemmerUtil.stem(word.toLowerCase()))) {
|
||||
selectedWords.add(word);
|
||||
|
||||
+12
-16
@@ -67,7 +67,7 @@ public class SearchableOptionsRegistrarImpl extends SearchableOptionsRegistrar {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.ide.ui.search.SearchableOptionsRegistrarImpl");
|
||||
public static final int LOAD_FACTOR = 20;
|
||||
@NonNls
|
||||
private static final Pattern REG_EXP = Pattern.compile("[\\W&&[^_-]]");
|
||||
private static final Pattern REG_EXP = Pattern.compile("[\\W&&[^-]]+");
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public SearchableOptionsRegistrarImpl() {
|
||||
@@ -360,14 +360,12 @@ public class SearchableOptionsRegistrarImpl extends SearchableOptionsRegistrar {
|
||||
Set<String> result = new HashSet<String>();
|
||||
@NonNls final String toLowerCase = text.toLowerCase();
|
||||
final String[] options = REG_EXP.split(toLowerCase);
|
||||
if (options != null) {
|
||||
for (String opt : options) {
|
||||
if (opt == null) continue;
|
||||
if (isStopWord(opt)) continue;
|
||||
final String processed = PorterStemmerUtil.stem(opt);
|
||||
if (isStopWord(processed)) continue;
|
||||
result.add(opt);
|
||||
}
|
||||
for (String opt : options) {
|
||||
if (isStopWord(opt)) continue;
|
||||
final String processed = PorterStemmerUtil.stem(opt);
|
||||
assert processed != null;
|
||||
if (isStopWord(processed)) continue;
|
||||
result.add(opt);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -376,13 +374,11 @@ public class SearchableOptionsRegistrarImpl extends SearchableOptionsRegistrar {
|
||||
Set<String> result = new HashSet<String>();
|
||||
@NonNls final String toLowerCase = text.toLowerCase();
|
||||
final String[] options = REG_EXP.split(toLowerCase);
|
||||
if (options != null) {
|
||||
for (String opt : options) {
|
||||
if (isStopWord(opt)) continue;
|
||||
opt = PorterStemmerUtil.stem(opt);
|
||||
if (opt == null) continue;
|
||||
result.add(opt);
|
||||
}
|
||||
for (String opt : options) {
|
||||
if (isStopWord(opt)) continue;
|
||||
opt = PorterStemmerUtil.stem(opt);
|
||||
assert opt != null;
|
||||
result.add(opt);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user