Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

Copy link
Copy link
@msftrncs

Description

@msftrncs
Issue body actions

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

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.