Skip to content

Commit

Permalink
powershell completion fix no file comp directive
Browse files Browse the repository at this point in the history
Make sure to filter the returned completions before we check if
there are valid completions left.

Fixes spf13#1362

Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
  • Loading branch information
Luap99 committed Mar 5, 2021
1 parent eb3b639 commit 7fa5fd1
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions powershell_completions.go
Expand Up @@ -140,19 +140,6 @@ Register-ArgumentCompleter -CommandName '%[1]s' -ScriptBlock {
$Space = ""
}
if (($Directive -band $ShellCompDirectiveNoFileComp) -ne 0 ) {
__%[1]s_debug "ShellCompDirectiveNoFileComp is called"
if ($Values.Length -eq 0) {
# Just print an empty string here so the
# shell does not start to complete paths.
# We cannot use CompletionResult here because
# it does not accept an empty string as argument.
""
return
}
}
if ((($Directive -band $ShellCompDirectiveFilterFileExt) -ne 0 ) -or
(($Directive -band $ShellCompDirectiveFilterDirs) -ne 0 )) {
__%[1]s_debug "ShellCompDirectiveFilterFileExt ShellCompDirectiveFilterDirs are not supported"
Expand All @@ -172,6 +159,19 @@ Register-ArgumentCompleter -CommandName '%[1]s' -ScriptBlock {
}
}
if (($Directive -band $ShellCompDirectiveNoFileComp) -ne 0 ) {
__%[1]s_debug "ShellCompDirectiveNoFileComp is called"
if ($Values.Length -eq 0) {
# Just print an empty string here so the
# shell does not start to complete paths.
# We cannot use CompletionResult here because
# it does not accept an empty string as argument.
""
return
}
}
# Get the current mode
$Mode = (Get-PSReadLineKeyHandler | Where-Object {$_.Key -eq "Tab" }).Function
__%[1]s_debug "Mode: $Mode"
Expand Down

0 comments on commit 7fa5fd1

Please sign in to comment.