Skip to content

tab completion of a provider path notation UNC share name is not possible #10002

Closed

Description

@msftrncs

related to #7569 and #9881

Steps to reproduce

Attempt to tab complete a share name on a UNC path via a partially resolved path that includes the provider notation.

get-content Microsoft.PowerShell.Core\FileSystem::\\rk-vs-fs1\ # press tab to cycle through the shares on the server.

Expected behavior

I expected the same completions that I get with

get-content \\rk-vs-fs1\ # press tab to cycle through the shares on the server.

Actual behavior

No completions occur

Analysis

Upon researching leads on #9881, it was noticed that this issue would occur in this code:

// First, try to match \\server\share
var shareMatch = Regex.Match(wordToComplete, "^\\\\\\\\([^\\\\]+)\\\\([^\\\\]*)$");
if (shareMatch.Success)
{
// Only match share names, no filenames.
var server = shareMatch.Groups[1].Value;
var sharePattern = WildcardPattern.Get(shareMatch.Groups[2].Value + "*", WildcardOptions.IgnoreCase);
var ignoreHidden = context.GetOption("IgnoreHiddenShares", @default: false);
var shares = GetFileShares(server, ignoreHidden);
foreach (var share in shares)
{
if (sharePattern.IsMatch(share))
{
string shareFullPath = "\\\\" + server + "\\" + share;
if (quote != string.Empty)
{
shareFullPath = quote + shareFullPath + quote;
}
results.Add(new CompletionResult(shareFullPath, shareFullPath, CompletionResultType.ProviderContainer, shareFullPath));
}
}
}
else

This particular code does not attempt to resolve the path name first to eliminate the potential 'filesystem' provider notation, before checking for a UNC '\server\share' pattern.

The 'filesystem' provider notation does not affect any other part of the tab completion logic, only the share name completion.

Do note, this code shown above appears to be responsible for #7569, as it fails to escape $ or spaces in the share names (or any other characters that might be legal in the share name but have a special meaning to PowerShell if not escaped or correctly quoted).

Activity

  1. added
    Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get a
    on Jun 25, 2019
  2. added
    Issue-Enhancementthe issue is more of a feature request than a bug
    and removed
    Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get a
    on Jun 26, 2019
  3. ghost added
    In-PRIndicates that a PR is out for the issue
    on Apr 2, 2023
  4. 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.

  5. 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.

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

  8. microsoft-github-policy-service commented on Feb 25, 2025

    @microsoft-github-policy-service
    Contributor

    📣 Hey Carl Morris (@msftrncs), how did we do? We would love to hear your feedback with the link below! 🗣️

    🔗 https://aka.ms/PSRepoFeedback

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

    In-PRIndicates that a PR is out for the issueIssue-Enhancementthe issue is more of a feature request than a bugWG-Interactive-IntelliSensetab completion

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions