Skip to content

tab-completion #1283

Closed
Closed

Description

@he852100

Tab is not valid when the parent directory case does not match

PS /root> tree ./cloudcone-cli/
./cloudcone-cli/
├── cloudcone-cli
├── cloudconecli-zhcn
├── powershell
│   ├── cloudcone-cli1.ps1
│   ├── cloudcone-cli.ps1
│   └── README.md
└── README.md

1 directory, 6 files
PS /root> ./Cloudcone-cli/p <tab>

Expected

./cloudcone-cli/powershell/

Activity

  1. msftrncs commented on Jan 6, 2020

    @msftrncs
    Collaborator

    What is your environment data from the new issue template script?

    I am thinking this is a known issue regarding case sensitive file systems, and it originates in PowerShell, not PSReadLine. PSReadLine does not perform the completions, PowerShell does, and PSReadLine just provides more UI features, such as the menu.

  2. he852100 commented on Jan 6, 2020

    @he852100
    Author
    PS version: 7.0.0-daily.20191219
    PSReadline version: 2.0.0-rc1
    os: Linux localhost 4.9.112-perf #1 SMP PREEMPT Mon Jan 7 10:46:47 KST 2019 aarch64 GNU/Linux
    PS file version: 7.0.0.0
    HostName: ConsoleHost
    BufferWidth: 66
    BufferHeight: 28
  3. daxian-dbw commented on Jan 6, 2020

    @daxian-dbw
    Member

    he852100 You mentioned the Expected behavior, but not the actual behavior in your PR description.
    Is the actual behavior that you got no tab completion? If that's the case, then it's by design because the Linux file system is case sensitive.

  4. he852100 commented on Jan 7, 2020

    @he852100
    Author

    When the tab is pressed. Case changes automatically, this is your default setting
    Suppose there is an a in the directory,

    /A/ <tab>
    /A/ <tab>
    

    There won't be any reaction,The desired result

    /a/
    

    In the example, expect C to be converted to c, the actual effect you can test yourself

    PS /root> ./Cloudcone-cli/p <tab>
    PS /root> ./cloudcone-cli/powershell/
    
  5. daxian-dbw commented on Jan 7, 2020

    @daxian-dbw
    Member

    I'm still confused with your repro steps, are you saying that ./c<tab> is completed to ./Cloudcone-cli/ with the capital C? I cannot reproduce this on both Ubuntu and macOS.

    tabcompletion

    Anyways, the bottom line is that PSReadLine depends on the tab completion API from PowerShell, and it just renders the returned completion results. You can use the TabExpansion2 function to check the completion results. For example, for the case shown in the above screen recording, running TabExpansion2 gets me the following results:

    [/private/tmp/test]
    PS:4> TabExpansion2 -inputScript './' | % CompletionMatches
    
    CompletionText  ListItemText         ResultType ToolTip
    --------------  ------------         ---------- -------
    ./cloudcone-cli cloudcone-cli ProviderContainer /private/tmp/test/cloudcone-cli
    
    [/private/tmp/test]
    PS:5> TabExpansion2 -inputScript './c' | % CompletionMatches
    
    CompletionText  ListItemText         ResultType ToolTip
    --------------  ------------         ---------- -------
    ./cloudcone-cli cloudcone-cli ProviderContainer /private/tmp/test/cloudcone-cli
    

    You can do the same on your repro machine and check the CompletionText property. If you found unexpected results, then file an issue in the PowerShell repo.

  6. he852100 commented on Jan 7, 2020

    @he852100
    Author

    What I want to say is

    /A/ <tab>
    /A/t <tab>
    /A/test/ <tab>
    

    to

    /a/
    /a/t***/
    /a/test/
    

    No

    /A <tab>
    

    to

    /a**/
    
  7. daxian-dbw commented on Jan 7, 2020

    @daxian-dbw
    Member

    Oh, I think I get what you meant.

    linux

    Clou<tab> can be completed to cloudcone-cli so you were expecting ./Cloudcone-cli/p<tab> to be completed to ./cloudcone-cli/powershell, namely PowerShell automatically fixing cases along the way.

    As has been said previously, tab completion is done by PowerShell instead of PSReadLine. Running TabExpansion2 will show you that there is not completion result returned from PowerShell in case of ./Cloudcone-cli/p<tab>:

    [/tmp/test]
    PS:78> TabExpansion2 -inputScript 'Clou' | % CompletionMatches
    
    CompletionText  ListItemText         ResultType ToolTip
    --------------  ------------         ---------- -------
    ./cloudcone-cli cloudcone-cli ProviderContainer /tmp/test/cloudcone-cli
    
    [/tmp/test]
    PS:79> TabExpansion2 -inputScript './Cloudcone-cli/p' | % CompletionMatches
    [/tmp/test]
    PS:80>
    

    Tab completion was made case insensitive for files and folders on case-insensitive file systems by this PR: PowerShell/PowerShell#8128
    I guess it only handles the leaf file and folder names, which is sufficient to address how most people use tab completion for paths. I haven't heard any complaints about its current behavior, but you are welcome to open an issue in the PowerShell repo to discuss your concerns.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions