From d078800830c533bdf44bf2b86365396597436b75 Mon Sep 17 00:00:00 2001 From: Sang Uk Park Date: Sun, 6 Oct 2024 20:02:28 +0900 Subject: [PATCH] handle error when the list is empty --- functions/_tide_pwd.fish | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/functions/_tide_pwd.fish b/functions/_tide_pwd.fish index 5447dd44..f8e781c8 100644 --- a/functions/_tide_pwd.fish +++ b/functions/_tide_pwd.fish @@ -28,8 +28,10 @@ eval "function _tide_pwd string match -qr \"(?\..|.)\" \$dir_section set -l glob \$parent_dir/\$trunc*/ - set -e glob[(contains -i \$parent_dir/\$dir_section/ \$glob)] # This is faster than inverse string match - + set -l indices (contains -i $parent_dir/$dir_section/ $glob) + if set -q indices[1] + set -e glob[$indices] + end while string match -qr \"^\$parent_dir/\$(string escape --style=regex \$trunc)\" \$glob && string match -qr \"(?\$(string escape --style=regex \$trunc).)\" \$dir_section end