Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

native cd completion #172

Closed
CircleCode opened this issue Jun 3, 2022 · 9 comments
Closed

native cd completion #172

CircleCode opened this issue Jun 3, 2022 · 9 comments

Comments

@CircleCode
Copy link

Question
is there a way to keep \cd native completion for <tab>?

Considerations
I have the feeling that I used to do cd D<tab> and to have native completion like with \cd D<tab>
But now (I don't know when things changed), cd D<tab> brings nothing

Note: I don't want ENHANCD_COMPLETION_BEHAVIOR, I want to have enhanced triggered only when I do cd<enter>

@babarot
Copy link
Owner

babarot commented Mar 25, 2023

@CircleCode

Sorry for the late reply. Thank you. I did cd D<tab> and got the following result:

I think it's almost what you want. What do you want on that action? (maybe I still may not be able to understand what you said.)

@CircleCode
Copy link
Author

@b4b4r07 Thanks for the update. On my side, it's still not working :-(

You can see the replay here: https://asciinema.org/a/FqTrA8MqMxBTInBrAe2vmBCr7

notes:

  • around 00:10, I'm using ba<tab> with no effect,
  • at 00:12, I'm using baz<tab> which returns the -- no matches found --

Any idea of what I can provide or dig to help debugging?

@babarot
Copy link
Owner

babarot commented Mar 31, 2023

Oh thank you for sharing the details! I'll work on this to fix. I'm thinking to remove all completion feature from enhancd at all now...

because:

  • Maintenance cost is high
  • Better to use native cd completion

Anyway I'll work on this in this weekend

@CircleCode
Copy link
Author

Thanks :-)

By the way, what were the completion features specific to enhancd and not available in native cd completion?

@babarot
Copy link
Owner

babarot commented Mar 31, 2023

@CircleCode

Can you try this branch? #191

By the way, what were the completion features specific to enhancd and not available in native cd completion?

Almost same as https://github.com/changyuheng/zsh-interactive-cd 's one! But I'm now thinking it's better to use this plugin, not enhancd's completion feature.

@CircleCode
Copy link
Author

CircleCode commented Mar 31, 2023

Hey @b4b4r07, what a fast update!

On my side, I dug a bit, and I found the issue is not directly related to enhancd built-in completion (thus the branch without completion had the same behaviour).
The problem was that zsh resolves the alias before launching completion (because the option COMPLETE_ALIASES is not enabled on my env).

On the other side, I have no idea why __enhancd::cd <tab> does not trigger completion (now that I think about it, maybe because the file completion.zsh is called before compinit is run, I will try to give it a try), but this is not a big deal on my side (and I will be happy without built-in completion)

For completeness and for people findig this issue, I found 2 workarounds:

  1. setopt COMPLETE_ALIASES (with its potential impact on other completions)
  2.  # use another completion for … (see https://unix.stackexchange.com/a/496759)
     compdefas () {
       if (($+_comps[$1])); then
         compdef $_comps[$1] ${^@[2,-1]}=$1
       fi
     }
         
     compdefas cd __enhancd::cd

edit: the problem came indeed from the fact that completion.zsh was sourced before the call to compinit. I use zinit to install enhancd, and calling zinit cdreplay solved the problem

@babarot
Copy link
Owner

babarot commented Mar 31, 2023

@CircleCode

Nice, thank you for the survey!

The problem was that zsh resolves the alias before launching completion (because the option COMPLETE_ALIASES is not enabled on my env).

Ah,.. I see. Nice catch, so super thanks. Thus it means we don't need to merge that PR, right..? Hmm. But actually I have already no much enough motivation to keep this completion feature now lol. So I'm thinking to merge that PR anyway.

On the other hands, we may need to think how we should solve this problem on enhancd.

@CircleCode
Copy link
Author

Thus it means we don't need to merge that PR, right..?

right

Hmm. But actually I have already no much enough motivation to keep this completion feature now lol.

I get it, and as said previously, on my side, I do not expect this kind of completion from enhancd, so I won't really persuade you to keep this feature!

On the other hands, we may need to think how we should solve this problem on enhancd.

Which problem are you talking about? I cannot anymore see a problem: on the branch with completion, we need to load it after the call of compinit (this is a user issue…), and on the branch without completion, either defining setopt COMPLETE_ALIASES or aliasing the completion like suggested in a previous comment makes it work like a charm!

@babarot
Copy link
Owner

babarot commented Apr 2, 2023

I've merged that PR. Thank you!

Which problem are you talking about? I cannot anymore see a problem: on the branch with completion, we need to load it after the call of compinit (this is a user issue…), and on the branch without completion, either defining setopt COMPLETE_ALIASES or aliasing the completion like suggested in a previous comment makes it work like a charm!

Thank you for the summary. What I wanted to say is that I might be better to mention about it in README or something. But this issue is helpful for those who's facing the same issue even if no annotations so I'll guide them to this issue at that time.

Anyway thank you for raising issue and investigating why this happens!

@babarot babarot closed this as completed Apr 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants