diff --git a/.github/workflows/continuous_integration.yml b/.github/workflows/continuous_integration.yml index 1d258279..801b997e 100644 --- a/.github/workflows/continuous_integration.yml +++ b/.github/workflows/continuous_integration.yml @@ -29,6 +29,8 @@ jobs: - name: Run full test suite run: fishtape tests/*/*.fish shell: fish {0} + # timeout in case tests get stuck on fzf + timeout-minutes: 3 syntax-check: runs-on: ubuntu-latest diff --git a/functions/__fzf_search_current_dir.fish b/functions/__fzf_search_current_dir.fish index 669dc643..43234eec 100644 --- a/functions/__fzf_search_current_dir.fish +++ b/functions/__fzf_search_current_dir.fish @@ -6,8 +6,8 @@ function __fzf_search_current_dir --description "Search the current directory. R set fd_opts --color=always $fzf_fd_opts set fzf_arguments --multi --ansi $fzf_dir_opts set token (commandline --current-token) - # expand ~ in the directory name since fd can't expand it - set expanded_token (string replace --regex -- "^~/" $HOME/ $token) + ​# expand the token (which may include tilde, variables, etc.) into full path + 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_var_in_query.fish b/tests/search_current_dir/expands_var_in_query.fish new file mode 100644 index 00000000..09388eed --- /dev/null +++ b/tests/search_current_dir/expands_var_in_query.fish @@ -0,0 +1,10 @@ +set target "file 1.txt" + +set --global fzf_dir_opts --select-1 +mock commandline --current-token "echo \$target" +mock commandline "--current-token --replace --" "echo \$argv" +mock commandline \* "" +# string unescape because the args passed into commandline --current-token --replace are escaped +set actual (string unescape (__fzf_search_current_dir)) + +@test "expands variables in current token" (basename $actual) = $target