public List <ItemInfo> Query(string query) { if (Index == null) { return(new List <ItemInfo>()); } if (!query.All(Char.IsLetter)) { return(PlainQuery(query, false)); } var regex = new Regex("^" + Regex.Escape(query), RegexOptions.IgnoreCase | RegexOptions.Compiled); var result = AbbrIndex.Where(i => regex.IsMatch(i.Item1)) .Concat(WordIndex.Where(i => regex.IsMatch(i.Item1))) .OrderBy(i => i.Item2) .ThenBy(i => i.Item3.Name, MyPathComparer) .ThenBy(i => i.Item3.Path, MyPathComparer) .Select(i => i.Item3) .ToList(); if (result.Count > 0) { return(result); } return(PlainQuery(query, true)); }