Skip to content
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
13 changes: 12 additions & 1 deletion cli/tests/shell_completions_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1137,6 +1137,7 @@ fn test_zsh_completion_init_integration() {

// Stub `compadd`/`_files` to capture what the handler offers without
// needing an interactive ZLE context. Drive with $words/$CURRENT.
// The fallback must preserve completion-friendly options for `_files`.
// The init template calls `compadd -l -d <display-arr> -U -Q -S '' -a <inserts-arr>`.
let test_script = format!(
r#"#!/usr/bin/env zsh
Expand All @@ -1152,7 +1153,9 @@ compadd() {{
print -r -- "[compadd:display] $d"
print -r -- "[compadd:inserts] $i"
}}
_files() {{ print -r -- "[files-fallback]" }}
_files() {{
print -r -- "[files-fallback] nomatch=$options[nomatch] extendedglob=$options[extendedglob]"
}}

words=(ex "")
CURRENT=2
Expand All @@ -1161,6 +1164,10 @@ _usage_default_complete
words=(ex "--f")
CURRENT=2
_usage_default_complete

words=(plain "")
CURRENT=2
_usage_default_complete
"#,
bin_dir = bin_dir.display(),
usage_dir = usage_bin.parent().unwrap().display(),
Expand Down Expand Up @@ -1189,6 +1196,10 @@ _usage_default_complete
stdout.contains("[compadd:display]") && stdout.contains("--foo"),
"expected --foo flag in compadd display, got: {stdout}"
);
assert!(
stdout.contains("[files-fallback] nomatch=off extendedglob=on"),
"expected file fallback to disable nomatch and enable extendedglob, got: {stdout}"
);

let _ = fs::remove_dir_all(&temp_dir);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ expression: "complete_zsh_init(\"usage\")"

_usage_default_complete() {
emulate -L zsh
setopt localoptions nonomatch extendedglob
local cmd cmdpath
cmd="${words[1]}"
if [[ "$cmd" == */* ]]; then
Expand Down
1 change: 1 addition & 0 deletions lib/src/complete/zsh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ pub fn complete_zsh_init(usage_bin: &str) -> String {

_usage_default_complete() {{
emulate -L zsh
setopt localoptions nonomatch extendedglob
local cmd cmdpath
cmd="${{words[1]}}"
if [[ "$cmd" == */* ]]; then
Expand Down