diff --git a/functions/__fzf_search_current_dir.fish b/functions/__fzf_search_current_dir.fish index 38432a7d..50c05f3e 100644 --- a/functions/__fzf_search_current_dir.fish +++ b/functions/__fzf_search_current_dir.fish @@ -7,7 +7,7 @@ function __fzf_search_current_dir --description "Search the current directory. R set fzf_arguments --multi --ansi $fzf_dir_opts set token (commandline --current-token) # expand any variables or leading tilde (~) in the token - set expanded_token (eval echo -- \"$token\") + set expanded_token (eval echo -- $token) # unescape token because it's already quoted so backslashes will mess up the path set unescaped_exp_token (string unescape -- $expanded_token) diff --git a/tests/search_current_dir/expands_~_base_dir.fish b/tests/search_current_dir/expands_~_base_dir.fish index 48f60a09..61f63905 100644 --- a/tests/search_current_dir/expands_~_base_dir.fish +++ b/tests/search_current_dir/expands_~_base_dir.fish @@ -3,7 +3,8 @@ function fd set fd_captured_opts $argv end mock fzf \* "" -mock commandline --current-token "echo ~/" +# escape tilde so it doesn't get expanded when echoed +mock commandline --current-token "echo \~/" mock commandline "--current-token --replace" "" mock commandline \* "" __fzf_search_current_dir diff --git a/tests/search_current_dir/no_base_dir_if_no_slash.fish b/tests/search_current_dir/no_base_dir_if_no_slash.fish index 709ae11a..4142402d 100644 --- a/tests/search_current_dir/no_base_dir_if_no_slash.fish +++ b/tests/search_current_dir/no_base_dir_if_no_slash.fish @@ -1,6 +1,7 @@ # though the conf.d directory exists, it should not be used as a base directory # because there is no / at the end of the token mock commandline --current-token "echo conf.d" +mock commandline "--current-token --replace" "" mock commandline \* "" set --export searched_functions_dir false