Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1329,7 +1329,8 @@ internal static List<CompletionResult> CompleteCommandArgument(CompletionContext
context.Options.Remove("LiteralPaths");
}

if (context.WordToComplete != string.Empty && context.WordToComplete.Contains('-'))
// The word to complete contains a dash and it's not the first character. We try command names in this case.
if (context.WordToComplete.IndexOf('-') > 0)
{
var commandResults = CompleteCommand(context);
if (commandResults != null)
Expand Down
7 changes: 7 additions & 0 deletions test/powershell/Host/TabCompletion/TabCompletion.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1378,6 +1378,13 @@ dir -Recurse `
$res = TabExpansion2 -inputScript $inputStr -cursorColumn $inputStr.Length
$res.CompletionMatches | Should -BeNullOrEmpty
}

It "A single dash should not complete to anything" {
function test-{}
$inputStr = 'git -'
$res = TabExpansion2 -inputScript $inputStr -cursorColumn $inputStr.Length
$res.CompletionMatches | Should -BeNullOrEmpty
}
}

Context "Tab completion error tests" {
Expand Down