Skip to content

Preserve order of supplied zsh completion candidates #775

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 18, 2025
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 @@ -23,7 +23,7 @@ extension [ParsableCommand.Type] {
\(completeFunctionName)() {
local -ar non_empty_completions=("${@:#(|:*)}")
local -ar empty_completions=("${(M)@:#(|:*)}")
_describe '' non_empty_completions -- empty_completions -P $'\\'\\''
_describe -V '' non_empty_completions -- empty_completions -P $'\\'\\''
}

\(customCompleteFunctionName)() {
Expand Down Expand Up @@ -83,7 +83,7 @@ extension [ParsableCommand.Type] {
.joined(separator: "\n")
)
)
_describe "subcommand" subcommands
_describe -V subcommand subcommands
;;
arg)
case "${words[1]}" in
Expand Down Expand Up @@ -195,7 +195,7 @@ extension [ParsableCommand.Type] {

case .shellCommand(let command):
return (
"{local -a list;list=(${(f)\"$(\(command.shellEscapeForSingleQuotedString()))\"});_describe \"\" list}",
"{local -a list;list=(${(f)\"$(\(command.shellEscapeForSingleQuotedString()))\"});_describe -V \"\" list}",
nil
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
__math_complete() {
local -ar non_empty_completions=("${@:#(|:*)}")
local -ar empty_completions=("${(M)@:#(|:*)}")
_describe '' non_empty_completions -- empty_completions -P $'\'\''
_describe -V '' non_empty_completions -- empty_completions -P $'\'\''
}

__math_custom_complete() {
Expand Down Expand Up @@ -55,7 +55,7 @@ _math() {
'stats:Calculate descriptive statistics.'
'help:Show subcommand help information.'
)
_describe "subcommand" subcommands
_describe -V subcommand subcommands
;;
arg)
case "${words[1]}" in
Expand Down Expand Up @@ -111,7 +111,7 @@ _math_stats() {
'stdev:Print the standard deviation of the values.'
'quantiles:Print the quantiles of the values (TBD).'
)
_describe "subcommand" subcommands
_describe -V subcommand subcommands
;;
arg)
case "${words[1]}" in
Expand Down Expand Up @@ -161,7 +161,7 @@ _math_stats_quantiles() {
':values:'
'--file:file:_files -g '\''*.txt *.md'\'''
'--directory:directory:_files -/'
'--shell:shell:{local -a list;list=(${(f)"$(head -100 /usr/share/dict/words | tail -50)"});_describe "" list}'
'--shell:shell:{local -a list;list=(${(f)"$(head -100 /usr/share/dict/words | tail -50)"});_describe -V "" list}'
'--custom:custom:{__math_custom_complete ---completion stats quantiles -- --custom "${current_word_index}" "$(__math_cursor_index_in_current_word)"}'
'--custom-deprecated:custom-deprecated:{__math_custom_complete ---completion stats quantiles -- --custom-deprecated}'
'--version[Show the version.]'
Expand Down
4 changes: 2 additions & 2 deletions Tests/ArgumentParserUnitTests/Snapshots/testBase_Zsh().zsh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
__base-test_complete() {
local -ar non_empty_completions=("${@:#(|:*)}")
local -ar empty_completions=("${(M)@:#(|:*)}")
_describe '' non_empty_completions -- empty_completions -P $'\'\''
_describe -V '' non_empty_completions -- empty_completions -P $'\'\''
}

__base-test_custom_complete() {
Expand Down Expand Up @@ -70,7 +70,7 @@ _base-test() {
'escaped-command:'
'help:Show subcommand help information.'
)
_describe "subcommand" subcommands
_describe -V subcommand subcommands
;;
arg)
case "${words[1]}" in
Expand Down