fixes flaw in implementation; adds additional test coverage
This commit is contained in:
parent
e891fc9942
commit
7ab8293fc9
22
src/shell.rs
22
src/shell.rs
|
@ -266,6 +266,28 @@ mod tests {
|
|||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn murex_template_has_direct_path_handling() {
|
||||
let opts = Opts { cmd: Some("z"), hook: InitHook::None, echo: false, resolve_symlinks: false };
|
||||
let source = Murex(&opts).render().unwrap();
|
||||
|
||||
// Ensure murex z handles: "-- path" and tries direct cd on single-arg
|
||||
assert!(
|
||||
source.contains("if { $__zoxide_argc == 2 && $PARAMS[0] == \"--\" }"),
|
||||
"murex template should handle literal path with --"
|
||||
);
|
||||
assert!(
|
||||
source.contains("fexec function __zoxide_cd $PARAMS[0]"),
|
||||
"murex template should attempt cd directly on single-arg"
|
||||
);
|
||||
|
||||
// Ensure __zoxide_zi exists (interactive-only)
|
||||
assert!(
|
||||
source.contains("fexec builtin function __zoxide_zi"),
|
||||
"murex template should define __zoxide_zi"
|
||||
);
|
||||
}
|
||||
|
||||
#[apply(opts)]
|
||||
fn tcsh_tcsh(cmd: Option<&str>, hook: InitHook, echo: bool, resolve_symlinks: bool) {
|
||||
let opts = Opts { cmd, hook, echo, resolve_symlinks };
|
||||
|
|
|
@ -52,6 +52,18 @@ fexec builtin function __zoxide_z {
|
|||
fexec function __zoxide_cd -
|
||||
fexec builtin return
|
||||
}
|
||||
# If a literal path is provided with "--", cd to it directly.
|
||||
if { $__zoxide_argc == 2 && $PARAMS[0] == "--" } then {
|
||||
fexec function __zoxide_cd $PARAMS[1]
|
||||
fexec builtin return
|
||||
}
|
||||
# If a single argument is provided, try cd directly; if it fails, fall back to query.
|
||||
if { $__zoxide_argc == 1 } then {
|
||||
trypipe <!null> {
|
||||
fexec function __zoxide_cd $PARAMS[0]
|
||||
fexec builtin return
|
||||
}
|
||||
}
|
||||
# Quiet query: capture result; suppress noise; return 1 on no match
|
||||
fexec builtin out '' -> set: str __zoxide_result
|
||||
trypipe <!null> {
|
||||
|
@ -66,7 +78,7 @@ fexec builtin function __zoxide_z {
|
|||
|
||||
# Jump to a directory using interactive search.
|
||||
fexec builtin function __zoxide_zi {
|
||||
# Quiet interactive query; return 1 when no selection
|
||||
# Interactive query; return 1 when no selection
|
||||
fexec builtin out '' -> set: str __zoxide_result
|
||||
trypipe <!null> {
|
||||
exec zoxide query --interactive -- @PARAMS -> set: str __zoxide_result
|
||||
|
|
Loading…
Reference in New Issue