diff --git a/CliFx.Tests/SuggestDirectiveSpecs.cs b/CliFx.Tests/SuggestDirectiveSpecs.cs index 2d908d18..19812744 100644 --- a/CliFx.Tests/SuggestDirectiveSpecs.cs +++ b/CliFx.Tests/SuggestDirectiveSpecs.cs @@ -94,13 +94,13 @@ private string FormatExpectedOutput(string [] s) [Theory] [InlineData("supply all commands if nothing supplied", "clifx.exe", 0, new[] { "cmd", "cmd02" })] - [InlineData("supply all commands that match partially", + [InlineData("supply all commands that 'start with' argument", "clifx.exe c", 0, new[] { "cmd", "cmd02" })] [InlineData("supply command options if match found, regardles of other partial matches (no options defined)", "clifx.exe cmd", 0, new string[] { })] - [InlineData("supply nothing if no partial match applies", - "clifx.exe cmd2", 0, new string[] { })] - [InlineData("supply all commands that match partially, allowing for cursor position", + [InlineData("supply nothing if no commands 'starts with' artument", + "clifx.exe m", 0, new string[] { })] + [InlineData("supply all commands that 'start with' argument, allowing for cursor position", "clifx.exe cmd", -2, new[] { "cmd", "cmd02" })] public async Task Suggest_directive_suggests_commands_by_environment_variables(string usecase, string variableContents, int cursorOffset, string[] expected) { diff --git a/CliFx/SuggestionService.cs b/CliFx/SuggestionService.cs index dc1f17f2..60370c4f 100644 --- a/CliFx/SuggestionService.cs +++ b/CliFx/SuggestionService.cs @@ -33,7 +33,7 @@ public IEnumerable GetSuggestions(CommandInput commandInput) if (commandMatch == null) { return _applicationSchema.GetCommandNames() - .Where(p => p.Contains(suggestInput.CommandName, StringComparison.OrdinalIgnoreCase)) + .Where(p => p.StartsWith(suggestInput.CommandName, StringComparison.OrdinalIgnoreCase)) .OrderBy(p => p) .ToList(); }