Skip to content

Commit 009bba4

Browse files
fabalchemyFabien Savy
authored andcommitted
fix(clap_complete): Improve powershell registration
1 parent d89d57d commit 009bba4

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

clap_complete/src/env/shells.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,15 @@ Register-ArgumentCompleter -Native -CommandName {bin} -ScriptBlock {{
286286
287287
$prev = $env:{var};
288288
$env:{var} = "powershell";
289+
290+
$args = $commandAst.Extent.Text
291+
$args = $args.Substring(0, [math]::Min($cursorPosition, $args.Length));
292+
if ($wordToComplete -eq "") {{
293+
$args += " ''";
294+
}}
295+
289296
$results = Invoke-Expression @"
290-
& {completer} -- $commandAst
297+
& {completer} -- $args
291298
"@;
292299
if ($null -eq $prev) {{
293300
Remove-Item Env:\{var};

0 commit comments

Comments
 (0)