Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Git-add completion should show full file paths

On Mon, Apr 27, 2020 at 12:24 PM dana <dana@xxxxxxx> wrote:
> I guess what Daniel is suggesting is basically an on/off switch for
> _multi_parts's intended function, and you can turn it off for git if you want.

That seems a bit off the mark to me?  Wouldn't the right approach here
be to call something OTHER THAN _multi_parts if you don't want the
strings treated as having multiple parts?

More specifically, _git_files already has the whole list in the $files
array, so instead of running
  _wanted $tag expl $description _multi_parts -f $compadd_opts - / files
it could instead just do
  _wanted $tag expl $description compadd -f $compadd_opts $files
(probably with some cleanup of subtleties I've ignored).

> I wonder if it could be more intelligent though — maybe this style could take
> an integer that acts as a threshold for whether it should work the normal way
> or the 'dumb' way? Like if there are more than x files with the same prefix or
> whatever. Not sure how you'd calculate it, but something like that.

That could be put into a wrapper function around the two possible
_wanted calls above, if it were desirable to have it somewhere other
than in _git_files.  Things do get a bit tricky if you're not passing
the -f option to compadd; you need something, other than the file
system, to which to compare the original strings.

> Also, whether it's like that or just a boolean, it seems like you'd also need
> to consider how recursive completion should work, or if it should, in the
> 'dumb' case. I think users are accustomed to being able to expand like
> f/b/b<TAB> -> foo/bar/baz with file paths

I think you'd just need to fall back on "_wanted _multi_parts" when
"_wanted compadd" didn't add anything.

Messages sorted by: Reverse Date, Date, Thread, Author