From 1e4a81e6598e625a1d695ccb575943948846ac9c Mon Sep 17 00:00:00 2001 From: Cole Helbling Date: Fri, 10 Apr 2020 15:06:23 -0700 Subject: [PATCH] Fix `cd`ing home when no matching directory in `fish` Prior to this change, executing `z sjlk` (assuming no `sjlk` directory in your database) would result in going back to the user's home. --- CHANGELOG.md | 4 ++++ src/subcommand/init.rs | 6 +----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e23105..9aefdaa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Interactive mode in `zoxide` no longer throws an error if `fzf` exits gracefully. - Canonicalize to regular paths instead of UNC paths on Windows. +### Fixed + +- When no match is found, `fish` stays in the current directory. + ## [0.3.1] - 2020-04-03 ### Added diff --git a/src/subcommand/init.rs b/src/subcommand/init.rs index e629bb5..4f5fa53 100644 --- a/src/subcommand/init.rs +++ b/src/subcommand/init.rs @@ -160,15 +160,11 @@ function {} or return $status else - # FIXME: use string-collect from fish 3.1.0 once it has wider adoption - set -l IFS '' set -l result (zoxide query $argv) - if test -d $result + if begin; test -d $result; and string length -q -- $result; end _z_cd $result or return $status - else if test -n "$result" - echo $result end end end