forked from mirror/cobra
powershell completion fix no file comp directive (#1363)
Make sure to filter the returned completions before we check if there are valid completions left. Fixes #1362 Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
This commit is contained in:
parent
06e4b59b20
commit
7223a997c8
|
@ -140,19 +140,6 @@ Register-ArgumentCompleter -CommandName '%[1]s' -ScriptBlock {
|
||||||
$Space = ""
|
$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
|
if ((($Directive -band $ShellCompDirectiveFilterFileExt) -ne 0 ) -or
|
||||||
(($Directive -band $ShellCompDirectiveFilterDirs) -ne 0 )) {
|
(($Directive -band $ShellCompDirectiveFilterDirs) -ne 0 )) {
|
||||||
__%[1]s_debug "ShellCompDirectiveFilterFileExt ShellCompDirectiveFilterDirs are not supported"
|
__%[1]s_debug "ShellCompDirectiveFilterFileExt ShellCompDirectiveFilterDirs are not supported"
|
||||||
|
@ -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
|
# Get the current mode
|
||||||
$Mode = (Get-PSReadLineKeyHandler | Where-Object {$_.Key -eq "Tab" }).Function
|
$Mode = (Get-PSReadLineKeyHandler | Where-Object {$_.Key -eq "Tab" }).Function
|
||||||
__%[1]s_debug "Mode: $Mode"
|
__%[1]s_debug "Mode: $Mode"
|
||||||
|
|
Loading…
Reference in New Issue