junegunn / fzf

:cherry_blossom: A command-line fuzzy finder
https://junegunn.github.io/fzf/
MIT License
64.33k stars 2.38k forks source link

fish shell: CTRL_T not starting fzf from specified file path #3755

Closed chentoast closed 5 months ago

chentoast commented 5 months ago

Checklist

Output of fzf --version

0.48.1 (brew)

OS

Shell

Problem / Steps to reproduce

When I use the CTRL_T command on fish to complete a command such as ls ~/Documents, fzf does not start searching within the Documents folder as expected, but instead searches with the current working directory.

It seems like the following change to line 42 of keybindings.fish (within the function fzf-file-widget) fixes it?

<       eval (__fzfcmd)' -m --query "'$fzf_query'"' | while read -l r; set result $result $r; end
---
>       eval (__fzfcmd)' -m --walker-root='$dir' --query "'$fzf_query'"'  | while read -l r; set result $result $r; end

Alternatively, the fix could also be in line 159 (within __fzf_parse_commandline) - the comment suggests that this line is meant to strip the trailing backslash, but the line as currently written instead removes any occurrences of $dir (with or without trailing backslash) from the commandline string.

<        set fzf_query (string replace -r "^$dir/?" -- '' "$commandline")
---
>        set fzf_query (string replace -r "^$dir/?" -- "$dir" "$commandline")

Let me know if I've misunderstood something here.

junegunn commented 5 months ago

Looks like a duplicate of https://github.com/junegunn/fzf/issues/3705. Please test with the latest version.