diff --git a/src/Cli/Microsoft.TemplateEngine.Cli/Commands/create/InstantiateCommand.TabCompletion.cs b/src/Cli/Microsoft.TemplateEngine.Cli/Commands/create/InstantiateCommand.TabCompletion.cs index 6f3ed7a3a0c7..9321052ab158 100644 --- a/src/Cli/Microsoft.TemplateEngine.Cli/Commands/create/InstantiateCommand.TabCompletion.cs +++ b/src/Cli/Microsoft.TemplateEngine.Cli/Commands/create/InstantiateCommand.TabCompletion.cs @@ -16,23 +16,23 @@ internal partial class InstantiateCommand : BaseCommand { private static readonly TimeSpan ConstraintEvaluationTimeout = TimeSpan.FromMilliseconds(1000); - internal static IEnumerable GetTemplateNameCompletions(string? tempalteName, IEnumerable templateGroups, IEngineEnvironmentSettings environmentSettings) + internal static IEnumerable GetTemplateNameCompletions(string? templateName, IEnumerable templateGroups, IEngineEnvironmentSettings environmentSettings) { TemplateConstraintManager constraintManager = new(environmentSettings); - if (string.IsNullOrWhiteSpace(tempalteName)) + if (string.IsNullOrWhiteSpace(templateName)) { return GetAllowedTemplateGroups(constraintManager, templateGroups) - .SelectMany(g => g.ShortNames, (g, shortName) => new CompletionItem(shortName, documentation: g.Description)) + .Select(g => new CompletionItem(g.ShortNames[0], documentation: g.Description)) .Distinct() .OrderBy(c => c.Label, StringComparer.OrdinalIgnoreCase) .ToArray(); } - IEnumerable matchingTemplateGroups = templateGroups.Where(t => t.ShortNames.Any(sn => sn.StartsWith(tempalteName, StringComparison.OrdinalIgnoreCase))); + IEnumerable matchingTemplateGroups = + templateGroups.Where(t => t.ShortNames.Any(sn => sn.StartsWith(templateName, StringComparison.OrdinalIgnoreCase))); return GetAllowedTemplateGroups(constraintManager, matchingTemplateGroups) - .SelectMany(g => g.ShortNames, (g, shortName) => new CompletionItem(shortName, documentation: g.Description)) - .Where(c => c.Label.StartsWith(tempalteName)) + .Select(g => new CompletionItem(g.ShortNames.First(sn => sn.StartsWith(templateName, StringComparison.OrdinalIgnoreCase)), documentation: g.Description)) .Distinct() .OrderBy(c => c.Label, StringComparer.OrdinalIgnoreCase) .ToArray(); diff --git a/src/Tests/Microsoft.TemplateEngine.Cli.UnitTests/ParserTests/Approvals/TabCompletionTests.Create_GetAllSuggestions.verified.txt b/src/Tests/Microsoft.TemplateEngine.Cli.UnitTests/ParserTests/Approvals/TabCompletionTests.Create_GetAllSuggestions.verified.txt index f81029a27953..d69e6215822b 100644 --- a/src/Tests/Microsoft.TemplateEngine.Cli.UnitTests/ParserTests/Approvals/TabCompletionTests.Create_GetAllSuggestions.verified.txt +++ b/src/Tests/Microsoft.TemplateEngine.Cli.UnitTests/ParserTests/Approvals/TabCompletionTests.Create_GetAllSuggestions.verified.txt @@ -48,13 +48,6 @@ InsertText: sln, Documentation: Create an empty solution containing no projects }, - { - Label: solution, - Kind: Value, - SortText: solution, - InsertText: solution, - Documentation: Create an empty solution containing no projects - }, { Label: tool-manifest, Kind: Value, diff --git a/src/Tests/Microsoft.TemplateEngine.Cli.UnitTests/ParserTests/Approvals/TabCompletionTests.RootCommand_GetAllSuggestions.verified.txt b/src/Tests/Microsoft.TemplateEngine.Cli.UnitTests/ParserTests/Approvals/TabCompletionTests.RootCommand_GetAllSuggestions.verified.txt index 67bd9b250165..b0148b9c2136 100644 --- a/src/Tests/Microsoft.TemplateEngine.Cli.UnitTests/ParserTests/Approvals/TabCompletionTests.RootCommand_GetAllSuggestions.verified.txt +++ b/src/Tests/Microsoft.TemplateEngine.Cli.UnitTests/ParserTests/Approvals/TabCompletionTests.RootCommand_GetAllSuggestions.verified.txt @@ -48,13 +48,6 @@ InsertText: sln, Documentation: Create an empty solution containing no projects }, - { - Label: solution, - Kind: Value, - SortText: solution, - InsertText: solution, - Documentation: Create an empty solution containing no projects - }, { Label: tool-manifest, Kind: Value, diff --git a/src/Tests/dotnet-new.Tests/Approvals/DotnetNewCompleteTests.CanDoTabCompletion.Linux.verified.txt b/src/Tests/dotnet-new.Tests/Approvals/DotnetNewCompleteTests.CanDoTabCompletion.Linux.verified.txt index 5e29de938dfe..92120a14418e 100644 --- a/src/Tests/dotnet-new.Tests/Approvals/DotnetNewCompleteTests.CanDoTabCompletion.Linux.verified.txt +++ b/src/Tests/dotnet-new.Tests/Approvals/DotnetNewCompleteTests.CanDoTabCompletion.Linux.verified.txt @@ -16,12 +16,10 @@ nunit nunit-test page proto -razor razorclasslib razorcomponent react sln -solution tool-manifest viewimports viewstart diff --git a/src/Tests/dotnet-new.Tests/Approvals/DotnetNewCompleteTests.CanDoTabCompletion.OSX.verified.txt b/src/Tests/dotnet-new.Tests/Approvals/DotnetNewCompleteTests.CanDoTabCompletion.OSX.verified.txt index 5e29de938dfe..92120a14418e 100644 --- a/src/Tests/dotnet-new.Tests/Approvals/DotnetNewCompleteTests.CanDoTabCompletion.OSX.verified.txt +++ b/src/Tests/dotnet-new.Tests/Approvals/DotnetNewCompleteTests.CanDoTabCompletion.OSX.verified.txt @@ -16,12 +16,10 @@ nunit nunit-test page proto -razor razorclasslib razorcomponent react sln -solution tool-manifest viewimports viewstart diff --git a/src/Tests/dotnet-new.Tests/Approvals/DotnetNewCompleteTests.CanDoTabCompletion.Windows.verified.txt b/src/Tests/dotnet-new.Tests/Approvals/DotnetNewCompleteTests.CanDoTabCompletion.Windows.verified.txt index 4927c3cb9381..a23a93e7763f 100644 --- a/src/Tests/dotnet-new.Tests/Approvals/DotnetNewCompleteTests.CanDoTabCompletion.Windows.verified.txt +++ b/src/Tests/dotnet-new.Tests/Approvals/DotnetNewCompleteTests.CanDoTabCompletion.Windows.verified.txt @@ -16,12 +16,10 @@ nunit nunit-test page proto -razor razorclasslib razorcomponent react sln -solution tool-manifest viewimports viewstart