Closed erhhung closed 4 months ago
When I made this functionality, I added a partial completion solely for some kind of compatibility of native behavior. In practice, I never used it myself, so I never ran into a problem. Just wondering why you need it. Basically, it just forces you to press Tab 2 times. Just got used to it?
It's often that one has files named with a common base followed by a digit, like:
foo_bar_baz1.txt
foo_bar_baz2.txt
foo_bar_baz8.txt
foo_bar_baz9.txt
foo_bar_baz_qux.txt
So when I type less foo
\<tab>, I'd like to first see less foo_bar_baz
partially completed, and then I can simply type 8
and hit tab again to do the full completion if I knew the exact number I need, instead of having to navigate down a possibly long list.
If I actually wanted to search for a foo*
file containing qux
from a popup, then I'd just hit tab twice.
The problem comes here
the next call fails
compgen -o bashdefault -o default -- "foo\ ba"
intuitive fix
compgen "${compgen_opts[@]}" -- "${2//\\/}"
partially correct the situation, but there are arises other problems with escaping I think @lincheney will be able to get into it easier
I had faced similar issue and I had reported it for fzf. cd to sub directory of directory with spaces does not work as slash gets removed
Reported another issue for this repo as well
I've made a number of changes https://github.com/lincheney/fzf-tab-completion/compare/b8e71337d3a78a67f858f0fcbc4193aff5cb0720...32fd6371a6e266c2c10239690e5d93a583c3c5e4 which I think fixes this issue, but it will need a bit of testing.
@lincheney Thanks for the fix! I've used it for a little while now and saw no more issues. I have so many files with spaces in their names that it has been driving me nuts...
@lincheney Thanks. I just tested it and didn't see the issue.
First, I'm using the standard setup in my
~/.bashrc
:Let's assume we have these files in a directory:
Here are some scenarios, with the second illustrating the problem:
$ less bar
\<tab> This works fine as there's only one match.$ less bar\ baz\ fred.txt
(cursor after trailing space)$ less foo
\<tab> Initial completion to common prefix works fine.$ less foo\ ba
(cursor right aftera
)$ less foo\ ba
\<tab> I'd would expect to see a popup with two choices, but the current partialcommand just repeats on a new line after the loading message flashes.
$ less foo\ ba
(cursor still right aftera
)Now delete a character, then hit tab, and repeat...
$ less foo\ b
\<tab> Same as above: existing partial command repeats.$ less foo\ b
(cursor still right afterb
)$ less foo\
\<tab> (cursor right after escaped space) *Hey, a popup! But I see all filenames instead of `foo`.**If I choose
foo\ bar\ baz.txt
from the list and hit Enter, theentire filename gets appended instead of completed to prefix,
and the completed prompt line is repeated on a separate line.
$ less foo\
$ less foo\ foo\ bar\ baz.txt
(cursor after trailing space)$ less qux
\<tab> Initial completion to common prefix works fine.$ less qux_ba
(cursor right aftera
)$ less qux_ba
\<tab> Popup appears with filtered choices, as expected!If I choose a file from the list and hit Enter, name completion works fine—on the same line.
$ less qux_baz_foo.txt
(cursor after trailing space)$ unset FZF_COMPLETION_AUTO_COMMON_PREFIX_PART
$ less foo
\<tab> Without partial common prefix completion, popup appears.Again, name completion works as expected—on the same line.
$ less foo\ bar\ baz.txt
(cursor after trailing space)