diff --git a/src/OmniSharp.Roslyn/Extensions/StringExtensions.cs b/src/OmniSharp.Roslyn/Extensions/StringExtensions.cs index aec86c914e..84d37e3777 100644 --- a/src/OmniSharp.Roslyn/Extensions/StringExtensions.cs +++ b/src/OmniSharp.Roslyn/Extensions/StringExtensions.cs @@ -31,6 +31,11 @@ public static bool IsSubsequenceMatch(this string completion, string partial) return true; } + if (partial.Length > 1 && completion.ToLowerInvariant().Contains(partial.ToLowerInvariant())) + { + return true; + } + // Limit the number of results returned by making sure // at least the first characters match. // We can get far too many results back otherwise. diff --git a/tests/OmniSharp.Roslyn.CSharp.Tests/FindSymbolsFacts.cs b/tests/OmniSharp.Roslyn.CSharp.Tests/FindSymbolsFacts.cs index 2513212dc9..f205ea4104 100644 --- a/tests/OmniSharp.Roslyn.CSharp.Tests/FindSymbolsFacts.cs +++ b/tests/OmniSharp.Roslyn.CSharp.Tests/FindSymbolsFacts.cs @@ -221,12 +221,39 @@ private string NestedMethod() {} var expected = new[] { "Method()", - "Method(string param)" + "Method(string param)", + "NestedMethod()" }; Assert.Equal(expected, symbols); } + [Fact] + public async Task Can_find_symbols_using_filter_with_subset_match() + { + const string code = @" + namespace Some.Long.Namespace + { + public class Options {} + public class Opossum {} + public interface IConfigurationOptions { } + public class ConfigurationOptions : IConfigurationOptions { } + }"; + + var usages = await FindSymbolsWithFilterAsync(code, "opti"); + var symbols = usages.QuickFixes.Select(q => q.Text); + + var expected = new[] + { + "Options", + "IConfigurationOptions", + "ConfigurationOptions" + }; + + Assert.Equal(expected, symbols); + } + + private async Task FindSymbolsAsync(string code) { var testFile = new TestFile("dummy.cs", code); diff --git a/tests/OmniSharp.Roslyn.CSharp.Tests/IntellisenseFacts.cs b/tests/OmniSharp.Roslyn.CSharp.Tests/IntellisenseFacts.cs index 13271dfb9f..e98f5e8c55 100644 --- a/tests/OmniSharp.Roslyn.CSharp.Tests/IntellisenseFacts.cs +++ b/tests/OmniSharp.Roslyn.CSharp.Tests/IntellisenseFacts.cs @@ -129,6 +129,23 @@ public Class1() ContainsCompletions(completions.Select(c => c.CompletionText).Take(1), "NewGuid"); } + [Theory] + [InlineData("dummy.cs")] + [InlineData("dummy.csx")] + public async Task Returns_sub_sequence_completions_without_matching_firstletter(string filename) + { + const string input = + @"public class Class1 { + public Class1() + { + System.Guid.gu$$ + } + }"; + + var completions = await FindCompletionsAsync(filename, input); + ContainsCompletions(completions.Select(c => c.CompletionText).Take(1), "NewGuid"); + } + [Theory] [InlineData("dummy.cs")] [InlineData("dummy.csx")]