Skip to content

Commit b61f270

Browse files
authored
Merge pull request #6369 from Metbcy/fix/zsh-completion-ordering
fix(complete): preserve candidate order in zsh completions
2 parents d142d8f + 74c6666 commit b61f270

3 files changed

Lines changed: 8 additions & 8 deletions

File tree

clap_complete/src/env/shells.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,8 +393,8 @@ function _clap_dynamic_completer_NAME() {
393393
other+=("$completion")
394394
fi
395395
done
396-
[[ -n $dirs ]] && _describe 'values' dirs -S '/' -r '/'
397-
[[ -n $other ]] && _describe 'values' other
396+
[[ -n $dirs ]] && _describe -V 'values' dirs -S '/' -r '/'
397+
[[ -n $other ]] && _describe -V 'values' other
398398
fi
399399
}
400400

clap_complete/tests/snapshots/home/dynamic-env/exhaustive/zsh/zsh/_exhaustive

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ function _clap_dynamic_completer_exhaustive() {
2828
other+=("$completion")
2929
fi
3030
done
31-
[[ -n $dirs ]] && _describe 'values' dirs -S '/' -r '/'
32-
[[ -n $other ]] && _describe 'values' other
31+
[[ -n $dirs ]] && _describe -V 'values' dirs -S '/' -r '/'
32+
[[ -n $other ]] && _describe -V 'values' other
3333
fi
3434
}
3535

clap_complete/tests/testsuite/zsh.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,11 +251,11 @@ fn complete_dynamic_env_toplevel() {
251251
let input = "exhaustive \t\t";
252252
let expected = snapbox::str![[r#"
253253
% exhaustive
254+
help -- Print this message or the help of the given subcommand(s)
254255
--generate -- generate
255256
--help -- Print help
256-
help -- Print this message or the help of the given subcommand(s)
257-
--empty-choice alias global last quote
258-
action empty hint pacman value
257+
empty action value last hint
258+
global quote pacman alias --empty-choice
259259
"#]];
260260
let actual = runtime.complete(input, &term).unwrap();
261261
assert_data_eq!(actual, expected);
@@ -430,7 +430,7 @@ fn complete_dynamic_dir_no_trailing_space() {
430430
let input = "exhaustive hint --file tests/\t\t";
431431
let expected = snapbox::str![[r#"
432432
% exhaustive hint --file tests/
433-
tests/examples.rs tests/snapshots tests/testsuite
433+
tests/snapshots tests/testsuite tests/examples.rs
434434
"#]];
435435
let actual = runtime.complete(input, &term).unwrap();
436436
assert_data_eq!(actual, expected);

0 commit comments

Comments
 (0)