Skip to content

Tab completion of paths prefixed by ~ does not work #4061

Closed

Description

@ixjlyons

cd /home/kenny/sr<TAB> correctly completes to cd /home/kenny/src whereas cd ~/sr<TAB> does not (though I can press the right arrow key to complete). I ran a bisect which identified a3a0692 as the offending commit.

Activity

  1. krader1961 commented on May 24, 2017

    @krader1961
    Contributor

    Good catch. Thanks for the bug report. This is an example of why we didn't want to include that change in the forthcoming 2.6.0 release. It wasn't clear that change wouldn't have negative side-effects.

    P.S., Pressing [right-arrow] is accepting the autosuggestion. Something that is independent of file name completions.

  2. zx8 commented on May 26, 2017

    @zx8

    In addition, this seems to have broken "partial matching" of directories as well, i.e.

    Expected

    $ ls
    aaaabbbb  bbbbaaa  cccccddddd
    $ cd d<TAB>
    $ cd cccccddddd/
    

    Actual

    $ ls
    aaaabbbb  bbbbaaa  cccccddddd
    $ cd d<TAB>
    [no results]
    
  3. faho commented on May 26, 2017

    @faho
    Member

    The issue here is that cd is using two kinds of completions - the script, and some hardcoded ones in c++. These latter ones are classified as "file" completions.

    The script does essentially one thing the hardcoded completions don't - for candidates from $CDPATH, it adds the corresponding $CDPATH-component as a description (which I find rather useful). On the other hand, it does not do various expansions, as you've seen here.

    There are a few things we can do:

    • Remove the cd.fish completion script since it's barely useful anyway - we can add the descriptions back later

    • Add these expansions to the cd.fish script (and then remove the special expansion code). This is difficult to do since we'd have to redo a bunch of the matching logic, and then keep it in sync.

    • Remove the "-x" from cd.fish - this makes it work immediately, and is exactly as clean as the status quo.

    Since the third option is really easy to do and fixes everything now, I'm going to do that.


    The good news is that we now know what to look out for when testing the underlying change - anything that might use the file-matching logic as a fallback for missing expansions, which includes everything using __fish_complete_directories.

    Most other completions won't be affected since they either use the builtin file-completion logic or don't accept files at all.

  4. modified the milestones: fish 2.7.0, fish-future on May 26, 2017
  5. zx8 commented on May 27, 2017

    @zx8

    @faho 4afd418 seems to have fixed the "partial completion" issue and the cd ~/<TAB> cases but cd ~<TAB> (without the / after ~) still seems to be broken (i.e. on my mac, it somehow autocompletes to cd ~_amavisd). Previously, it would autocomplete all the directories within ~.

  6. faho commented on May 27, 2017

    @faho
    Member

    cd ~ (without the / after ~) still seems to be broken (i.e. on my mac, it somehow autocompletes to cd ~_amavisd)

    That means you have a user called "_amavisd" - tilde-expansion covers not just ~/ for the current user's home, but also ~$USER/ for $USER's home. E.g. on my system ~root/ expands to "/root/".

    This isn't directly caused by the change to not offer files. It is caused by c114cbc since that breaks on the first match.

    @krader1961: Mind taking a look?

  7. zx8 commented on May 27, 2017

    @zx8

    @faho Aha, I see. I'm assuming also related to c114cbc, it seems to complete ~_amavisd even if the target directory doesn't exist:

    $ grep _amavisd /etc/passwd
    _amavisd:*:83:83:AMaViS Daemon:/var/virusmails:/usr/bin/false
    
    $ cd ~_amavisd
    cd: The directory '/private/var/virusmails' does not exist
    
  8. faho commented on May 27, 2017

    @faho
    Member

    it seems to complete ~_amavisd even if the target directory doesn't exist

    I'm unsure if we should do anything about that. That is what the "_amavisd" user's $HOME is set to, and it might be useful for some commands. I'm assuming the path is still marked as non-existing (i.e. it's not underlined)?

    Anyway, I've now opened #4074 to track the ~/ issue (which I don't was ever offered as a completion).

  9. faho commented on May 27, 2017

    @faho
    Member

    Also #4075 tracks the issue of only completing one user.

  10. locked as resolved and limited conversation to collaborators on Apr 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugregression

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions