Skip to content

Commit 085143d

Browse files
authored
Merge pull request #5722 from epage/sort
fix(complete): Put clap in chage of Fish ordering
2 parents 19460ee + e2d336b commit 085143d

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

clap_complete/src/env/shells.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ impl EnvCompleter for Fish {
226226

227227
writeln!(
228228
buf,
229-
r#"complete -x -c {bin} -a "({var}=fish "'{completer}'" -- (commandline --current-process --tokenize --cut-at-cursor) (commandline --current-token))""#
229+
r#"complete --keep-order --exclusive --command {bin} --arguments "({var}=fish "'{completer}'" -- (commandline --current-process --tokenize --cut-at-cursor) (commandline --current-token))""#
230230
)
231231
}
232232
fn write_complete(
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
complete -x -c exhaustive -a "(COMPLETE=fish "'exhaustive'" -- (commandline --current-process --tokenize --cut-at-cursor) (commandline --current-token))"
1+
complete --keep-order --exclusive --command exhaustive --arguments "(COMPLETE=fish "'exhaustive'" -- (commandline --current-process --tokenize --cut-at-cursor) (commandline --current-token))"

clap_complete/tests/testsuite/fish.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -191,12 +191,12 @@ fn complete_dynamic_env_toplevel() {
191191

192192
let input = "exhaustive \t\t";
193193
let expected = snapbox::str![[r#"
194-
% exhaustive action
195-
action pacman --generate (generate)
196-
alias quote --global (everywhere)
197-
help (Print this message or the help of the given subcommand(s)) value --help (Print help)
198-
hint -h (Print help) --version (Print version)
199-
last -V (Print version)
194+
% exhaustive --global
195+
--global (everywhere) -V (Print version) last
196+
--generate (generate) action pacman
197+
--help (Print help) alias quote
198+
--version (Print version) help (Print this message or the help of the given subcommand(s)) value
199+
-h (Print help) hint
200200
"#]];
201201
let actual = runtime.complete(input, &term).unwrap();
202202
assert_data_eq!(actual, expected);
@@ -215,6 +215,18 @@ fn complete_dynamic_env_quoted_help() {
215215
let input = "exhaustive quote \t\t";
216216
let expected = snapbox::str![[r#"
217217
% exhaustive quote
218+
--single-quotes (Can be 'always', 'auto', or 'never')
219+
--double-quotes (Can be "always", "auto", or "never")
220+
--backticks (For more information see `echo test`)
221+
--backslash (Avoid '/n')
222+
--brackets (List packages [filter])
223+
--expansions (Execute the shell command with $SHELL)
224+
--choice
225+
--global (everywhere)
226+
--help (Print help (see more with '--help'))
227+
--version (Print version)
228+
-h (Print help (see more with '--help'))
229+
-V (Print version)
218230
cmd-backslash (Avoid '/n')
219231
cmd-backticks (For more information see `echo test`)
220232
cmd-brackets (List packages [filter])
@@ -223,18 +235,6 @@ cmd-expansions (Execute the shell command with $SHELL)
223235
cmd-single-quotes (Can be 'always', 'auto', or 'never')
224236
escape-help (/tab "')
225237
help (Print this message or the help of the given subcommand(s))
226-
-h (Print help (see more with '--help'))
227-
-V (Print version)
228-
--backslash (Avoid '/n')
229-
--backticks (For more information see `echo test`)
230-
--brackets (List packages [filter])
231-
--choice
232-
--double-quotes (Can be "always", "auto", or "never")
233-
--expansions (Execute the shell command with $SHELL)
234-
--global (everywhere)
235-
--help (Print help (see more with '--help'))
236-
--single-quotes (Can be 'always', 'auto', or 'never')
237-
--version (Print version)
238238
"#]];
239239
let actual = runtime.complete(input, &term).unwrap();
240240
assert_data_eq!(actual, expected);

0 commit comments

Comments
 (0)