Skip to content

Commit

Permalink
Tyrrrz#13 - Change from 'contain' matching to 'starts with' matching.
Browse files Browse the repository at this point in the history
  • Loading branch information
mauricel committed Mar 31, 2021
1 parent f34bc00 commit 6122d6f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions CliFx.Tests/SuggestDirectiveSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion CliFx/SuggestionService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public IEnumerable<string> 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();
}
Expand Down

0 comments on commit 6122d6f

Please sign in to comment.