Open glykos opened 5 years ago
This seems to only happen with the preview pane on... so the culprit is somewhere with this {1}
and {2}
splits, but I'm not sure how to resolve this atm.
I'm having the same problem. In addition, while the preview pane doesn't actually show the parts of the directory name after the space, when you select a directory from it the whole directory including the space and whatever is after the space does get substituted into the command. However, the space is not escaped with a backslash and therefore the substituted directory is incorrect.
@jethrokuan Mind explaining what the --preview="fish\ '$file'\ __fzf_complete_preview\ '{1}'\ '{2..}'"
part of this code does (I'm not super familiar with this syntax)? I'm trying to dig in and fix this problem. I've tested it out a bit and I've confirmed that this line is passing each part of the selected directory (split by spaces) to the preview pane function __fzf_complete_preview
.
Sorry for not getting back, have been pretty busy. I'm not familiar with this portion of the code itself, maybe @vic (who wrote these completion widgets) can help us out better?
I just ended up losing a bit of work due to this issue. I'm not using the preview pane at all. (set -U FZF_COMPLETE 0
)
I had both a Library
folder and a Calibre Library
folder, and I wanted to delete the Calibre Library
folder, but it resulted in
-> rm -rfv Cali<TAB>
...
-> rm -rfv Calibre Library
removed directory 'Library/'
I feel like the expected behaviour is for each line passed to fzf
to be quoted.
@reisub0 it's unfortunate that you've lost work because of that. I looked into this again, and am brought back to https://github.com/fish-shell/fish-shell/issues/3469. The crux of the issue is that for this completion widget to function correctly, the result of complete -C
needs to be properly escaped where necessary.
complete -C
returns in each line 2 items, tab-delimited. First item is the completion itself, and the second item is the description. For example, for me:
jethro@jethro ~/projects> complete -C"git"
git Executable, 2.2MB
git-receive-pack Executable link, 2.2MB
git-shell Executable, 1.2MB
git-upload-archive Executable link, 2.2MB
git-upload-pack Executable, 1.3MB
I could parse each line, separate by tab, and escape the first item, but what about completions that may have tabs within them, e.g. file descriptors with tab characters? I'm hoping this is fixed upstream, but I'll add a caveat in the wiki page.
@jethrokuan for myself, I solved the problem as follows (It works fine for daily work): change two lines in functions/__fzf_complete.fish 100: commandline -t -- (string escape -n -- $r) 125: echo --preview-window=right:wrap --preview="fish\ '$file'\ __fzf_complete_preview\ '{1..}'"
@jethrokuan it seems like https://github.com/fish-shell/fish-shell/issues/3469 has been fixed and merged! (via https://github.com/fish-shell/fish-shell/pull/8645)
@Koljasha your workaround works great for me! Thanks for finding the spot. 🙂 To the group, would that approach work to outright resolve this issue? Or are there limitations it imposes that I'm not aware of? Seems like "escape fzf's completions" is basically exactly what's called for here. 🤔
Just moving over from zsh to fish and this is probably the last issue I have.
The workaround provided by @Koljasha fixes the tab complete for me. Preview is still borked with spaces. But, it seems that string escape
is the answer.
Using TAB completion with directories containing spaces in their names appears to be broken (?). I attach two screenshots with and without FZF_COMPLETE to illustrate the issue.
Without FZF TAB completion :
With TAB completion, notice the missing part of the directory name :