Skip to content

Commit 9245fe8

Browse files
authored
Fixes issue for which folder shortcuts open in explorer (#3276)
1 parent 707f530 commit 9245fe8

File tree

1 file changed

+31
-12
lines changed

1 file changed

+31
-12
lines changed

Files/Interacts/Interaction.cs

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -448,11 +448,7 @@ public async Task<bool> OpenPath(string path, FilesystemItemType? itemType = nul
448448

449449
if (itemType == null || isShortcutItem || isHiddenItem)
450450
{
451-
if (isHiddenItem)
452-
{
453-
itemType = NativeFileOperationsHelper.HasFileAttribute(path, System.IO.FileAttributes.Directory) ? FilesystemItemType.Directory : FilesystemItemType.File;
454-
}
455-
else if (isShortcutItem)
451+
if (isShortcutItem)
456452
{
457453
AppServiceResponse response = await Connection.SendMessageAsync(new ValueSet()
458454
{
@@ -469,13 +465,17 @@ public async Task<bool> OpenPath(string path, FilesystemItemType? itemType = nul
469465
shortcutRunAsAdmin = response.Message.Get("RunAsAdmin", false);
470466
shortcutIsFolder = response.Message.Get("IsFolder", false);
471467

472-
itemType = FilesystemItemType.File; // Set to file here, because the logic is the same in both scenarios
468+
itemType = shortcutIsFolder ? FilesystemItemType.Directory : FilesystemItemType.File;
473469
}
474470
else
475471
{
476472
return false;
477473
}
478474
}
475+
else if (isHiddenItem)
476+
{
477+
itemType = NativeFileOperationsHelper.HasFileAttribute(path, System.IO.FileAttributes.Directory) ? FilesystemItemType.Directory : FilesystemItemType.File;
478+
}
479479
else
480480
{
481481
itemType = await StorageItemHelpers.GetTypeFromPath(path, AssociatedInstance);
@@ -486,7 +486,26 @@ public async Task<bool> OpenPath(string path, FilesystemItemType? itemType = nul
486486

487487
if (itemType == FilesystemItemType.Directory) // OpenDirectory
488488
{
489-
if (isHiddenItem)
489+
if (isShortcutItem)
490+
{
491+
if (string.IsNullOrEmpty(shortcutTargetPath))
492+
{
493+
await InvokeWin32ComponentAsync(path);
494+
return true;
495+
}
496+
else
497+
{
498+
AssociatedInstance.NavigationToolbar.PathControlDisplayText = shortcutTargetPath;
499+
AssociatedInstance.ContentFrame.Navigate(AssociatedInstance.InstanceViewModel.FolderSettings.GetLayoutType(shortcutTargetPath), new NavigationArguments()
500+
{
501+
NavPathParam = shortcutTargetPath,
502+
AssociatedTabInstance = AssociatedInstance
503+
}, new SuppressNavigationTransitionInfo());
504+
505+
return true;
506+
}
507+
}
508+
else if (isHiddenItem)
490509
{
491510
AssociatedInstance.NavigationToolbar.PathControlDisplayText = path;
492511
AssociatedInstance.ContentFrame.Navigate(AssociatedInstance.InstanceViewModel.FolderSettings.GetLayoutType(path), new NavigationArguments()
@@ -522,11 +541,7 @@ public async Task<bool> OpenPath(string path, FilesystemItemType? itemType = nul
522541
}
523542
else if (itemType == FilesystemItemType.File) // OpenFile
524543
{
525-
if (isHiddenItem)
526-
{
527-
await InvokeWin32ComponentAsync(path);
528-
}
529-
else if (isShortcutItem)
544+
if (isShortcutItem)
530545
{
531546
if (string.IsNullOrEmpty(shortcutTargetPath))
532547
{
@@ -547,6 +562,10 @@ public async Task<bool> OpenPath(string path, FilesystemItemType? itemType = nul
547562
}
548563
opened = (FilesystemResult)true;
549564
}
565+
else if (isHiddenItem)
566+
{
567+
await InvokeWin32ComponentAsync(path);
568+
}
550569
else
551570
{
552571
opened = await AssociatedInstance.FilesystemViewModel.GetFileWithPathFromPathAsync(path)

0 commit comments

Comments
 (0)