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

Alias completions with external completers does not work anymore (after #8123) #8483

Open
thomasgoulet opened this issue Mar 16, 2023 · 5 comments
Labels
alias Issues around support for command aliases, touches parser and name resolution completions Issues related to tab completion regression Something that worked does not work anymore.

Comments

@thomasgoulet
Copy link

Describe the bug

I use fish as a completer with the exact same setup as in the docs.

Before, in 0.76 I could alias k = kubectl and get automcompletion for the resource names from the fish completion file (kubectl completion fish)

In 0.77, this completion does not work anymore and I have to use the full command to get completion.

How to reproduce

  1. alias k = kubectl
  2. > k get pods <TAB>

(0. Have kubectl installed and external completion setup)

Expected behavior

Autocomplete as if I typed kubectl get pods.

Screenshots

image

(Not screenshotting expected behavior because I'm at work)

Configuration

key value
version 0.77.0
branch makepkg
commit_hash fd09609
build_os linux-x86_64
build_target x86_64-unknown-linux-gnu
rust_version rustc 1.68.0 (2c8cc3432 2023-03-06) (Arch Linux rust 1:1.68.0-1)
cargo_version cargo 1.68.0
build_time 2023-03-15 09:27:56 +00:00
build_rust_channel release
features default, zip
installed_plugins

Additional context

No response

@sholderbach
Copy link
Member

I think this is a subissue of the regression observed in #8471. So the changes to the aliases do not play nice with the completions yet.

@thomasgoulet
Copy link
Author

I think this is a subissue of the regression observed in #8471. So the changes to the aliases do not play nice with the completions yet.

The issue you mentioned is within 0.76.1, so the new alias changes were not in place.

@sholderbach sholderbach added completions Issues related to tab completion regression Something that worked does not work anymore. alias Issues around support for command aliases, touches parser and name resolution labels Mar 18, 2023
@bartlibert
Copy link

I also have this issue and I noticed that aliases get expanded wrongly when passed to the external completer.
For example, I have an alias alias gp = git push.
I noticed parameters that are passed to the completer in this case are gp push instead of git push.
So it seems the alias is expanded, but the first part is not replaced with the first part of the expanded alias.

I have the following (ugly) workaround in my config and this seems to work (for carapace):

let carapace_completer = {|spans|
    let has_alias = ($nu.scope.aliases | where name == $spans.0)
    let spans = (if not ($has_alias | is-empty) {
      # put the first word of the expanded alias first in the span
      $spans | skip 1 | prepend ($has_alias | get expansion | split words | get 0)
    } else { $spans })
    carapace $spans.0 nushell $spans | from json

@aserowy
Copy link

aserowy commented Aug 14, 2023

Heho,

any progress on this issue?

Kind regards
Alexander

aserowy added a commit to aserowy/dots that referenced this issue Aug 14, 2023
@aserowy
Copy link

aserowy commented Aug 14, 2023

I also have this issue and I noticed that aliases get expanded wrongly when passed to the external completer. For example, I have an alias alias gp = git push. I noticed parameters that are passed to the completer in this case are gp push instead of git push. So it seems the alias is expanded, but the first part is not replaced with the first part of the expanded alias.

I have the following (ugly) workaround in my config and this seems to work (for carapace):

let carapace_completer = {|spans|
    let has_alias = ($nu.scope.aliases | where name == $spans.0)
    let spans = (if not ($has_alias | is-empty) {
      # put the first word of the expanded alias first in the span
      $spans | skip 1 | prepend ($has_alias | get expansion | split words | get 0)
    } else { $spans })
    carapace $spans.0 nushell $spans | from json

Heho,

fyi. This snippet is not working anymore. In the cookbook is a running workaround.

Regards
Alexander

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
alias Issues around support for command aliases, touches parser and name resolution completions Issues related to tab completion regression Something that worked does not work anymore.
Projects
None yet
Development

No branches or pull requests

4 participants