File tree Expand file tree Collapse file tree 2 files changed +14
-12
lines changed
src/System.Management.Automation/engine/CommandCompletion
test/powershell/Host/TabCompletion Expand file tree Collapse file tree 2 files changed +14
-12
lines changed Original file line number Diff line number Diff line change @@ -4629,22 +4629,19 @@ private static List<CompletionResult> GetFileSystemProviderResults(
4629
4629
string basePath ;
4630
4630
if ( ! relativePaths )
4631
4631
{
4632
- string providerName = $ "{ provider . ModuleName } \\ { provider . Name } ::";
4633
- if ( pathInfo . Path . StartsWith ( providerName , StringComparison . OrdinalIgnoreCase ) )
4632
+ if ( pathInfo . Drive is null )
4634
4633
{
4635
- basePath = pathInfo . Path . Substring ( providerName . Length ) ;
4634
+ basePath = dirInfo . FullName ;
4636
4635
}
4637
4636
else
4638
4637
{
4639
- providerName = $ "{ provider . Name } ::";
4640
- if ( pathInfo . Path . StartsWith ( providerName , StringComparison . OrdinalIgnoreCase ) )
4641
- {
4642
- basePath = pathInfo . Path . Substring ( providerName . Length ) ;
4643
- }
4644
- else
4645
- {
4646
- basePath = pathInfo . Path ;
4647
- }
4638
+ int stringStartIndex = pathInfo . Drive . Root . EndsWith ( provider . ItemSeparator ) && pathInfo . Drive . Root . Length > 1
4639
+ ? pathInfo . Drive . Root . Length - 1
4640
+ : pathInfo . Drive . Root . Length ;
4641
+
4642
+ basePath = pathInfo . Drive . VolumeSeparatedByColon
4643
+ ? string . Concat ( pathInfo . Drive . Name , ":" , dirInfo . FullName . AsSpan ( stringStartIndex ) )
4644
+ : string . Concat ( pathInfo . Drive . Name , dirInfo . FullName . AsSpan ( stringStartIndex ) ) ;
4648
4645
}
4649
4646
4650
4647
basePath = basePath . EndsWith ( provider . ItemSeparator )
Original file line number Diff line number Diff line change @@ -1276,6 +1276,11 @@ class InheritedClassTest : System.Attribute
1276
1276
}
1277
1277
}
1278
1278
1279
+ It ' Should correct slashes in UNC path completion' - Skip:(! $IsWindows ) {
1280
+ $Res = TabExpansion2 - inputScript ' Get-ChildItem //localhost/c$/Windows'
1281
+ $Res.CompletionMatches [0 ].CompletionText | Should - Be " '\\localhost\c$\Windows'"
1282
+ }
1283
+
1279
1284
It ' Should keep custom drive names when completing file paths' {
1280
1285
$TempDriveName = " asdf"
1281
1286
$null = New-PSDrive - Name $TempDriveName - PSProvider FileSystem - Root $HOME
You can’t perform that action at this time.
0 commit comments