diff options
author | Mike Krüger <mkrueger@xamarin.com> | 2016-01-19 20:06:52 +0300 |
---|---|---|
committer | Mike Krüger <mkrueger@xamarin.com> | 2016-01-19 20:07:04 +0300 |
commit | 7d5b256b254f7dedb30795f47f2376802cce1ba2 (patch) | |
tree | b34a2aa2ecbdc2df35ed8f54b915ef66a4c0f014 /main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/FileSearchCategory.cs | |
parent | db52fb13d874da9bd78b229924fb49609381f64f (diff) |
[Ide] Fixed possible null reference exception.
Diffstat (limited to 'main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/FileSearchCategory.cs')
-rw-r--r-- | main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/FileSearchCategory.cs | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/FileSearchCategory.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/FileSearchCategory.cs index 960d80e4ba..4eda2000c4 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/FileSearchCategory.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/FileSearchCategory.cs @@ -85,24 +85,23 @@ namespace MonoDevelop.Components.MainToolbar return Task.Run (delegate { var files = AllFiles.ToList (); var matcher = StringMatcher.GetMatcher (pattern.Pattern, false); - savedMatches = new Dictionary<string, MatchResult> (); + var savedMatches = new Dictionary<string, MatchResult> (); foreach (ProjectFile file in files) { if (token.IsCancellationRequested) break; int rank; string matchString = System.IO.Path.GetFileName (file.FilePath); - if (MatchName (matcher, matchString, out rank)) + if (MatchName (savedMatches, matcher, matchString, out rank)) searchResultCallback.ReportResult (new FileSearchResult (pattern.Pattern, matchString, rank, file, true)); matchString = FileSearchResult.GetRelProjectPath (file); - if (MatchName (matcher, matchString, out rank)) + if (MatchName (savedMatches, matcher, matchString, out rank)) searchResultCallback.ReportResult (new FileSearchResult (pattern.Pattern, matchString, rank, file, true)); } - savedMatches = null; - }, token); + }, token); } - bool MatchName (StringMatcher matcher, string name, out int matchRank) + static bool MatchName (Dictionary<string, MatchResult> savedMatches, StringMatcher matcher, string name, out int matchRank) { if (name == null) { matchRank = -1; @@ -118,7 +117,6 @@ namespace MonoDevelop.Components.MainToolbar return savedMatch.Match; } - Dictionary<string, MatchResult> savedMatches = new Dictionary<string, MatchResult> (); } } |