Skip to content

Commit a27d4bd

Browse files
authored
Merge pull request #3409 from babysnakes/powershell-allow-completion-of-partial-commands
Allow completion of partial commands
2 parents 5674587 + c90a48b commit a27d4bd

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

clap_complete/src/shells/powershell.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ Register-ArgumentCompleter -Native -CommandName '{bin_name}' -ScriptBlock {{
3737
$element = $commandElements[$i]
3838
if ($element -isnot [StringConstantExpressionAst] -or
3939
$element.StringConstantType -ne [StringConstantType]::BareWord -or
40-
$element.Value.StartsWith('-')) {{
40+
$element.Value.StartsWith('-') -or
41+
$element.Value -eq $wordToComplete) {{
4142
break
4243
}}
4344
$element.Value

clap_complete/tests/completions/powershell.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ Register-ArgumentCompleter -Native -CommandName 'my_app' -ScriptBlock {
5252
$element = $commandElements[$i]
5353
if ($element -isnot [StringConstantExpressionAst] -or
5454
$element.StringConstantType -ne [StringConstantType]::BareWord -or
55-
$element.Value.StartsWith('-')) {
55+
$element.Value.StartsWith('-') -or
56+
$element.Value -eq $wordToComplete) {
5657
break
5758
}
5859
$element.Value
@@ -123,7 +124,8 @@ Register-ArgumentCompleter -Native -CommandName 'my_app' -ScriptBlock {
123124
$element = $commandElements[$i]
124125
if ($element -isnot [StringConstantExpressionAst] -or
125126
$element.StringConstantType -ne [StringConstantType]::BareWord -or
126-
$element.Value.StartsWith('-')) {
127+
$element.Value.StartsWith('-') -or
128+
$element.Value -eq $wordToComplete) {
127129
break
128130
}
129131
$element.Value
@@ -222,7 +224,8 @@ Register-ArgumentCompleter -Native -CommandName 'cmd' -ScriptBlock {
222224
$element = $commandElements[$i]
223225
if ($element -isnot [StringConstantExpressionAst] -or
224226
$element.StringConstantType -ne [StringConstantType]::BareWord -or
225-
$element.Value.StartsWith('-')) {
227+
$element.Value.StartsWith('-') -or
228+
$element.Value -eq $wordToComplete) {
226229
break
227230
}
228231
$element.Value

0 commit comments

Comments
 (0)