Skip to content

Tab completion: do not tab-complete filenames when binding to non-string parameters #14147

Closed

Description

The default tab-completion (command-completion) behavior for command arguments is to complete based on the names of items in the current location (typically, files and directories present in the current file-system directory).

However, this completion is currently also performed for arguments that will bind to parameters other than untyped or [string]-typed (or perhaps also System.IO.FileInfo / System.IO.DirectoryInfo) parameters, e.g. [int], in which case such completions make no sense.

(By contrast, custom completions, validation attributes, and enum-derived types are handled correctly.)

Steps to reproduce

$line = 'function foo { param([int] $bar) $bar }; foo '

(TabExpansion2 $line $line.Length).CompletionMatches.Count | Should -Be 0

Expected behavior

The test should succeed.
That is, no completion should occur, because tab-completing an [int] value (without validation attributes / custom completions) makes no sense.

Actual behavior

The test fails, because completion based on the item names (files and directories) in the current directory was performed:

Expected 0, but got 526.

Environment data

PowerShell Core 7.2.0-preview.1

Activity

  1. added
    Issue-Question
    on Nov 19, 2020
  2. iSazonov commented on Nov 22, 2020

    @iSazonov
    Collaborator

    The last resort was always in PowerShell for non-implemented branches of the IntelliSense. So a request should be specific and positive - "to add support for IntelliSense for ... case". I suspect there are many such cases out there.

  3. mklement0 commented on Nov 22, 2020

    @mklement0
    ContributorAuthor

    Ilya (@iSazonov): This proposal is properly framed negatively: it is about generically excluding tab-completion behavior that is self-evidently never helpful.

    To put it differently: it is specific about when not to apply the fallback behavior.

  4. iSazonov commented on Nov 22, 2020

    @iSazonov
    Collaborator

    This proposal is properly framed negatively:

    I believe all current branches in implementation is positive and this is more positive :-) than adding negative conditions.

  5. mklement0 commented on Nov 22, 2020

    @mklement0
    ContributorAuthor

    The proposal is about adding an exclusion (negative) to the fallback condition/branch (positive, in a sense).

    It means that when the "last resort" is reached that the fallback behavior should only be applied when it is at least potentially helpful; or, conversely, it shouldn't be applied when it is unequivocally unhelpful.

  6. added
    Resolution-No Activity
    on Nov 16, 2023
  7. 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

    Issue-QuestionResolution-No ActivityWG-Interactive-IntelliSense

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions