From 2c0c026432ada80c238f36ed34cf34d2dfa8c989 Mon Sep 17 00:00:00 2001 From: Nick Nungester Date: Wed, 5 Mar 2025 23:22:36 -0500 Subject: [PATCH 1/4] fix: ensure dirs arent empty strings This fixes issue 564 also safely wraps strings for parsing [564] --- functions/_tide_parent_dirs.fish | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/functions/_tide_parent_dirs.fish b/functions/_tide_parent_dirs.fish index 9f31b043..5eefdc4e 100644 --- a/functions/_tide_parent_dirs.fish +++ b/functions/_tide_parent_dirs.fish @@ -1,7 +1,11 @@ function _tide_parent_dirs --on-variable PWD - set -g _tide_parent_dirs (string escape ( - for dir in (string split / -- $PWD) - set -la parts $dir - string join / -- $parts - end)) + set -g _tide_parent_dirs ( + string escape ( + for dir in (string split / -- $PWD) + if test (string length \"$dir\") -lt 1 + continue + end + set -a parts $dir + string join "" (string join / -- $parts) "" + end)) end From 35cdab85c5a5c3c7ce651bd27f3c1e55b3d1ad00 Mon Sep 17 00:00:00 2001 From: Nick Nungester Date: Tue, 18 Mar 2025 09:03:40 -0400 Subject: [PATCH 2/4] fix: scope parts variable to function --- functions/_tide_parent_dirs.fish | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/_tide_parent_dirs.fish b/functions/_tide_parent_dirs.fish index 5eefdc4e..d011082c 100644 --- a/functions/_tide_parent_dirs.fish +++ b/functions/_tide_parent_dirs.fish @@ -5,7 +5,7 @@ function _tide_parent_dirs --on-variable PWD if test (string length \"$dir\") -lt 1 continue end - set -a parts $dir + set -fa parts $dir string join "" (string join / -- $parts) "" end)) end From 2363b2eea83c94889d2c4f59885c4a75c3f8dd5f Mon Sep 17 00:00:00 2001 From: Nick Nungester Date: Tue, 18 Mar 2025 09:13:27 -0400 Subject: [PATCH 3/4] chore: fix formatting --- functions/_tide_parent_dirs.fish | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/functions/_tide_parent_dirs.fish b/functions/_tide_parent_dirs.fish index d011082c..f408a22d 100644 --- a/functions/_tide_parent_dirs.fish +++ b/functions/_tide_parent_dirs.fish @@ -7,5 +7,7 @@ function _tide_parent_dirs --on-variable PWD end set -fa parts $dir string join "" (string join / -- $parts) "" - end)) + end + ) + ) end From 16d8dba77dbec2e53d22e9228c710c7c3c43240f Mon Sep 17 00:00:00 2001 From: Nick Nungester Date: Tue, 25 Mar 2025 21:54:24 -0400 Subject: [PATCH 4/4] fix: remove hacky length test, clean up join credit to @scaryrawr where credit is due. --- functions/_tide_parent_dirs.fish | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/functions/_tide_parent_dirs.fish b/functions/_tide_parent_dirs.fish index f408a22d..00d8a14a 100644 --- a/functions/_tide_parent_dirs.fish +++ b/functions/_tide_parent_dirs.fish @@ -2,11 +2,8 @@ function _tide_parent_dirs --on-variable PWD set -g _tide_parent_dirs ( string escape ( for dir in (string split / -- $PWD) - if test (string length \"$dir\") -lt 1 - continue - end set -fa parts $dir - string join "" (string join / -- $parts) "" + string join / -- $parts end ) )