Skip to content

Auto-completion doesn't work for non build-in commands and path with [] #14015

Closed

Description

@Nino-kun

Path auto-completion doesn't work for non build-in commands if path contain square brackets symbols.

Steps to reproduce

New-Item -Type File -Name '[test].txt'
Copy-Item '``[ + <TAB> work and became Copy-Item '.\`[test`].txt'
notepad  '``[ + <TAB> doesn't work

Expected behavior

TAB-key auto-complete path for any command.

Actual behavior

Path auto-completion doesn't work if command not pwsh build-in.

Environment data

PSVersion                      7.0.3
PSEdition                      Core
GitCommitId                    7.0.3
OS                             Microsoft Windows 10.0.19042
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Activity

  1. added
    Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get a
    on Nov 9, 2020
  2. hv0905 commented on Jul 29, 2022

    @hv0905

    The issue still exists after nearly 2 years... I hope it can be fixed.
    Even worse, the built-in command also can't work with the autocomplete in this case.

    Repro

    image
    In this case, I can't perform an autocomplete.

    image
    Neither this.

  3. Nino-kun commented on Jul 30, 2022

    @Nino-kun
    Author

    Powershell is really non-intuitive in that part.
    Autocompletion work most of the time, but some time it request adding special characters, and some time it doesn't work at all.
    Your examples won't work because of one backtick character <`>. If you write two backticks, it will.

    cat '.\`[ + <TAB> - don't work
    cat '.\``[ + <TAB> - work
    cat .\``[ + <TAB> - don't work again, because single quote symbol missing.

  4. MartinGC94 commented on Apr 12, 2023

    @MartinGC94
    Contributor

    Hello, I'm currently working on improving the path completion (see: #19489 ).
    When I look at this issue I think the user expectations are wrong.
    The point of tab completion is to make it intelligently complete what you intended, based on your partial input. So if you want to complete the filename: [test].txt you shouldn't have to escape the wildcard characters yourself, you should just type them in as is and let the tab completion take care of escaping. So I would expect that the following examples should work:

    cat [<Tab>
    cat [te<Tab>
    cat .\[<Tab>
    cat .\[te<Tab>
    

    This also means that if you type in a backtick, it would look for that literally, and that's what my current implementation does:

    cd C:\Users\Martin\TestFolder\
    New-Item -Type File -Name '[test].txt'
    New-Item -Type File -Name '`[test].txt
    
    .\`[<Tab>        -> & '.\`[test].txt'
    .\[<Tab>         -> .\[test].txt
    notepad '[<Tab>  -> notepad '.\[test].txt'
    notepad '`[<Tab> -> notepad '.\`[test].txt'
    

    Do you agree that this is a better way to do it? Or is there something I'm missing?

  5. Nino-kun commented on Apr 12, 2023

    @Nino-kun
    Author

    I really like your suggestion, it's intuitive and simple.

    Will it always work as intended? Can't say, i'm not a programmer. The maximum I can say is that some cmdlets have -Path and -LiteralPath keys, which interpret characters in names differently. Path require escaping some "special" characters, LiteralPath treat all characters literally.

  6. microsoft-github-policy-service commented on Nov 16, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

  7. microsoft-github-policy-service commented on Nov 16, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

  8. microsoft-github-policy-service commented on Nov 16, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

  9. microsoft-github-policy-service commented on Nov 23, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes.

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

    Area-FileSystem-Providerspecific to the FileSystem providerIssue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-No ActivityIssue has had no activity for 6 months or moreWG-Interactive-IntelliSensetab completion

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions