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

An ArgumentCompleter script block returning no results should not result in falling back to the default tab-completion behavior #7215

Closed
mklement0 opened this issue Jun 30, 2018 · 5 comments
Labels
Issue-Discussion the issue may not have a clear classification yet. The issue may generate an RFC or may be reclassif Resolution-No Activity Issue has had no activity for 6 months or more WG-Engine core PowerShell engine, interpreter, and runtime

Comments

@mklement0
Copy link
Contributor

Currently, if you attach an ArgumentCompleterAttribute to a parameter and its script block happens to return no completions, tab completion falls back to the default behavior, i.e., completion of item names in the current location (which, in a filesystem location, cycles through the names of all files and directories in the current directory).

However, it makes more sense to not complete in this event, given that the intended completions may be unrelated to provider items altogether.

Steps to reproduce

Assume that the current location is a filesystem location and that no *.ext files are present.

function foo {
  param(
    [ArgumentCompleter({
      Get-ChildItem -Name *.ext
    })]
    [string] $Bar
  )

  $Bar
}

foo # <-- press TAB here

Expected behavior

A no-op: given that the argument-completer script block outputs no completions, nothing should happen.

Actual behavior

Tab completion falls back to the default behavior and cycles through the names of all files and subdirectories in the current dir.

Environment data

Written as of:

PowerShell Core v6.1.0-preview.3
@iSazonov iSazonov added WG-Engine core PowerShell engine, interpreter, and runtime Issue-Discussion the issue may not have a clear classification yet. The issue may generate an RFC or may be reclassif labels Jul 3, 2018
@Betoz
Copy link

Betoz commented Dec 13, 2022

Attaching ArgumentCompletions attribute with empty string as the only tab completion value, i.e. [ArgumentCompletions('')], in addition to ArgumentCompleter attribute, results in no completion when ArgumentCompleter script block returns no completions.

I agree with it making more sense to not complete when ArgumentCompleter script block returns no completions, or at least to handling the return of empty string as a valid completion, like it does for the ArgumentCompletions attribute.

Maybe it is a design decision to use ArgumentCompletions for static completions in the case of ArgumentCompleter script block returning no completions?
If so, I would like this information in the about_functions_argument_completion documentation, e.g.

Hey! You can block tab completion with [ArgumentCompletions('')].

Note that the ArgumentCompletions attribute was introduced in PowerShell 6.0.

I confirmed usage of [ArgumentCompletions('')] to work with PowerShell 7.1.2, and to not work with 5.1 (breaks, because not supported).

Copy link
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.

2 similar comments
Copy link
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.

Copy link
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.

@microsoft-github-policy-service microsoft-github-policy-service bot added Resolution-No Activity Issue has had no activity for 6 months or more labels Nov 16, 2023
Copy link
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
Labels
Issue-Discussion the issue may not have a clear classification yet. The issue may generate an RFC or may be reclassif Resolution-No Activity Issue has had no activity for 6 months or more WG-Engine core PowerShell engine, interpreter, and runtime
Projects
None yet
Development

No branches or pull requests

3 participants