Browse Source

Feature Request: Search by abbreviated qualified name when not performing a full name search

pull/1119/head
Rafaat Mir 8 years ago
parent
commit
40cadf0191
  1. 26
      ILSpy/SearchStrategies.cs

26
ILSpy/SearchStrategies.cs

@ -17,6 +17,7 @@ namespace ICSharpCode.ILSpy @@ -17,6 +17,7 @@ namespace ICSharpCode.ILSpy
protected string[] searchTerm;
protected Regex regex;
protected bool fullNameSearch;
protected bool allowNonContiguousMatch;
protected AbstractSearchStrategy(params string[] terms)
{
@ -114,10 +115,35 @@ namespace ICSharpCode.ILSpy @@ -114,10 +115,35 @@ namespace ICSharpCode.ILSpy
}
break;
default:
if (!fullNameSearch && allowNonContiguousMatch) {
if (!IsNonContiguousMatch(text.ToLower(), term.ToLower()))
return false;
} else {
if (text.IndexOf(term, StringComparison.OrdinalIgnoreCase) < 0)
return false;
}
break;
}
}
return true;
}
private bool IsNonContiguousMatch(string text, string searchTerm)
{
if (string.IsNullOrEmpty(text) || string.IsNullOrEmpty(searchTerm)) {
return false;
}
var index = 0;
foreach (char c in searchTerm) {
while (index != text.Length) {
if (text[index] == c) {
index++;
break;
}
index++;
}
if (index == text.Length)
return false;
}
return true;
}

Loading…
Cancel
Save