Skip to content

Commit 1c03ca4

Browse files
Feature: Show drive name on tab header (#10889)
1 parent 341e56c commit 1c03ca4

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/Files.App/ViewModels/MainPageViewModel.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -296,15 +296,17 @@ public static async Task UpdateTabInfo(TabItem tabItem, object navigationArg)
296296
}
297297
else
298298
{
299-
var matchingCloudDrive = App.CloudDrivesManager.Drives.FirstOrDefault(x => PathNormalization.NormalizePath(currentPath).Equals(PathNormalization.NormalizePath(x.Path), StringComparison.OrdinalIgnoreCase));
299+
var normalizedCurrentPath = PathNormalization.NormalizePath(currentPath);
300+
var matchingCloudDrive = App.CloudDrivesManager.Drives.FirstOrDefault(x => normalizedCurrentPath.Equals(PathNormalization.NormalizePath(x.Path), StringComparison.OrdinalIgnoreCase));
300301
if (matchingCloudDrive is not null)
301302
{
302303
tabLocationHeader = matchingCloudDrive.Text;
303304
}
304-
else if (PathNormalization.NormalizePath(PathNormalization.GetPathRoot(currentPath)) == PathNormalization.NormalizePath(currentPath)) // If path is a drive's root
305+
else if (PathNormalization.NormalizePath(PathNormalization.GetPathRoot(currentPath)) == normalizedCurrentPath) // If path is a drive's root
305306
{
306-
var matchingNetDrive = App.NetworkDrivesManager.Drives.FirstOrDefault(x => PathNormalization.NormalizePath(currentPath).Contains(PathNormalization.NormalizePath(x.Path), StringComparison.OrdinalIgnoreCase));
307-
tabLocationHeader = matchingNetDrive is not null ? matchingNetDrive.Text : PathNormalization.NormalizePath(currentPath);
307+
var matchingDrive = App.NetworkDrivesManager.Drives.FirstOrDefault(netDrive => normalizedCurrentPath.Contains(PathNormalization.NormalizePath(netDrive.Path), StringComparison.OrdinalIgnoreCase));
308+
matchingDrive ??= App.DrivesManager.Drives.FirstOrDefault(drive => normalizedCurrentPath.Contains(PathNormalization.NormalizePath(drive.Path), StringComparison.OrdinalIgnoreCase));
309+
tabLocationHeader = matchingDrive is not null ? matchingDrive.Text : normalizedCurrentPath;
308310
}
309311
else
310312
{

0 commit comments

Comments
 (0)