Browse Source

Enable search by abbreviated qualified name by prefixing search string with "s:"

pull/1119/head
Rafaat Mir 8 years ago
parent
commit
0f69536673
  1. 9
      ILSpy/SearchStrategies.cs

9
ILSpy/SearchStrategies.cs

@ -14,10 +14,11 @@ namespace ICSharpCode.ILSpy
{ {
abstract class AbstractSearchStrategy abstract class AbstractSearchStrategy
{ {
private const string NoncontiguousSearchPrefix = "s:";
protected string[] searchTerm; protected string[] searchTerm;
protected Regex regex; protected Regex regex;
protected bool fullNameSearch; protected bool fullNameSearch;
protected bool allowNonContiguousMatch;
protected AbstractSearchStrategy(params string[] terms) protected AbstractSearchStrategy(params string[] terms)
{ {
@ -115,8 +116,8 @@ namespace ICSharpCode.ILSpy
} }
break; break;
default: default:
if (!fullNameSearch && allowNonContiguousMatch) { if (term.Length > 2 && term.StartsWith(NoncontiguousSearchPrefix, StringComparison.OrdinalIgnoreCase)) {
if (!IsNonContiguousMatch(text.ToLower(), term.ToLower())) if (!IsNoncontiguousMatch(text.ToLower(), term.Substring(2).ToLower()))
return false; return false;
} else { } else {
if (text.IndexOf(term, StringComparison.OrdinalIgnoreCase) < 0) if (text.IndexOf(term, StringComparison.OrdinalIgnoreCase) < 0)
@ -128,7 +129,7 @@ namespace ICSharpCode.ILSpy
return true; return true;
} }
private bool IsNonContiguousMatch(string text, string searchTerm) private bool IsNoncontiguousMatch(string text, string searchTerm)
{ {
if (string.IsNullOrEmpty(text) || string.IsNullOrEmpty(searchTerm)) { if (string.IsNullOrEmpty(text) || string.IsNullOrEmpty(searchTerm)) {
return false; return false;

Loading…
Cancel
Save