From bd1d81d22eb170f27cfcc5640e89255e8584e842 Mon Sep 17 00:00:00 2001 From: Rafaat Mir Date: Sun, 17 Jun 2018 12:04:05 -0700 Subject: [PATCH] Change '~' to be the 'In-string Search' Activator Prefix and Fix Search Not Matching Last Character Bug --- ILSpy/SearchStrategies.cs | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/ILSpy/SearchStrategies.cs b/ILSpy/SearchStrategies.cs index f9e3cfe01..1a560a37d 100644 --- a/ILSpy/SearchStrategies.cs +++ b/ILSpy/SearchStrategies.cs @@ -115,14 +115,13 @@ namespace ICSharpCode.ILSpy return false; } break; + case '~': + if (term.Length > 1 && !IsNoncontiguousMatch(text.ToLower(), term.Substring(1).ToLower())) + return false; + break; default: - if (term.Length > 2 && term.StartsWith(NoncontiguousSearchPrefix, StringComparison.OrdinalIgnoreCase)) { - if (!IsNoncontiguousMatch(text.ToLower(), term.Substring(2).ToLower())) - return false; - } else { - if (text.IndexOf(term, StringComparison.OrdinalIgnoreCase) < 0) - return false; - } + if (text.IndexOf(term, StringComparison.OrdinalIgnoreCase) < 0) + return false; break; } } @@ -138,20 +137,22 @@ namespace ICSharpCode.ILSpy if (searchTerm.Length > textLength) { return false; } - var index = 0; - foreach (char c in searchTerm) { - while (index != textLength) { - if (text[index] == c) { - index++; + var i = 0; + for (int searchIndex = 0; searchIndex < searchTerm.Length;) { + while (i != textLength) { + if (text[i] == searchTerm[searchIndex]) { + // Check if all characters in searchTerm have been matched + if (searchTerm.Length == ++searchIndex) + return true; + i++; break; } - index++; - } - // Check if we reached end of text without matching the full search string - if (index == textLength) + i++; + } + if (i == textLength) return false; } - return true; + return false; } string GetLanguageSpecificName(Language language, IMemberDefinition member, bool fullName = false)