jethrokuan / z

Pure-fish z directory jumping
MIT License
1.26k stars 44 forks source link

TAB completion not showing complete path #71

Closed manuel-uberti closed 5 years ago

manuel-uberti commented 5 years ago

Hi,

first of all thanks for z.

I am using latest z (updated through fisher) on Fish 3.0.0, and I have this in my config.fish:

# Use j instead of z to jump to directories
set -U Z_CMD "j"

Whenever I try to jump to a previously visited directory, hitting TAB does not complete the path. So, for instance:

~
❯ j pla█

If I hit Enter, I end up in a directory (which in this particular case is the directory I want, but it isn't always the case).

But if I hit TAB, I get nothing:

~
❯ j pla █

Is this intended?

jethrokuan commented 5 years ago

Hi,

This is definitely not intended, but I can reproduce this as well.

However, it doesn't look like something I can easily fix. The code has already been written to generate the completions once, after the function definition: https://github.com/jethrokuan/z/blob/master/conf.d/z.fish#L40

Completions do indeed work after manually running __z_complete. This seems to be a situation where the lines here:

https://github.com/jethrokuan/z/blob/master/conf.d/z.fish#L23-L27

takes a while to define the function, and completes only after __z_complete is run, causing the completions to be produced before the function is defined and are hence invalid.

manuel-uberti commented 5 years ago

I'm not really familiar with Fish code, so I'm not sure how to help here. You can count me in for tests, though. :)

jethrokuan commented 5 years ago

what I was trying to get is that there's nothing much I can do here, the behaviour we're seeing is (I'm guessing) a result of some race condition that arises from how fish evaluates the code.

manuel-uberti commented 5 years ago

Probably worth mentioning @faho then, and see if he's got some clue about this.

faho commented 5 years ago

Simple: There is already a thing called "j", and fish ships completions for it.

Since z does not ship a completion file, it'll still autoload that one, and that includes:

complete -c j -e

which will erase all completions for the "j" command.

manuel-uberti commented 5 years ago

Thanks @faho, I confirm that using the default z instead of j works as expected.

jethrokuan commented 5 years ago

Thanks @faho, closing as it's resolved

manuel-uberti commented 5 years ago

Well, actually I'd like to have j working, but it's ok. :)