diff --git a/src/Files.App/Actions/Navigation/OpenInNewWindow/BaseOpenInNewWindowAction.cs b/src/Files.App/Actions/Navigation/OpenInNewWindow/BaseOpenInNewWindowAction.cs index d89469546cfb..2881300bb8a8 100644 --- a/src/Files.App/Actions/Navigation/OpenInNewWindow/BaseOpenInNewWindowAction.cs +++ b/src/Files.App/Actions/Navigation/OpenInNewWindow/BaseOpenInNewWindowAction.cs @@ -11,6 +11,7 @@ internal abstract class BaseOpenInNewWindowAction : ObservableObject, IAction protected IContentPageContext ContentPageContext { get; } = Ioc.Default.GetRequiredService(); protected IHomePageContext HomePageContext { get; } = Ioc.Default.GetRequiredService(); protected ISidebarContext SidebarContext { get; } = Ioc.Default.GetRequiredService(); + protected IStorageTrashBinService StorageTrashBinService { get; } = Ioc.Default.GetRequiredService(); public string Label => Strings.OpenInNewWindow.GetLocalizedResource(); @@ -49,6 +50,9 @@ public virtual async Task ExecuteAsync(object? parameter = null) foreach (ListedItem listedItem in items) { var selectedItemPath = (listedItem as IShortcutItem)?.TargetPath ?? listedItem.ItemPath; + if (StorageTrashBinService.IsUnderTrashBin(selectedItemPath)) + selectedItemPath = Uri.EscapeDataString(Constants.UserEnvironmentPaths.RecycleBinPath); + var folderUri = new Uri($"files-dev:?folder={@selectedItemPath}"); await Launcher.LaunchUriAsync(folderUri); diff --git a/src/Files.App/Views/Layouts/ColumnsLayoutPage.xaml.cs b/src/Files.App/Views/Layouts/ColumnsLayoutPage.xaml.cs index a90df6a8281f..5f674cc34218 100644 --- a/src/Files.App/Views/Layouts/ColumnsLayoutPage.xaml.cs +++ b/src/Files.App/Views/Layouts/ColumnsLayoutPage.xaml.cs @@ -103,8 +103,34 @@ protected override void OnNavigatedTo(NavigationEventArgs eventArgs) var path = navigationArguments.NavPathParam; var pathRoot = GetPathRoot(path); var pathStack = new Stack(); + var storageTrashBinService = Ioc.Default.GetRequiredService(); + if (storageTrashBinService.IsUnderTrashBin(path)) + { + var recycleBinPath = $"{pathRoot}$Recycle.Bin"; + var tempPath = path; + var pathsToAdd = new List(); + + while (!string.IsNullOrEmpty(tempPath)) + { + var parentPath = GetParentDir(tempPath); + + if (!string.IsNullOrEmpty(parentPath) && parentPath.Equals(recycleBinPath, StringComparison.OrdinalIgnoreCase)) + // SID folder? stop here + break; + + if (tempPath.Equals(recycleBinPath, StringComparison.OrdinalIgnoreCase)) + break; - if (!string.IsNullOrEmpty(pathRoot)) + pathsToAdd.Add(tempPath); + tempPath = parentPath; + } + + foreach (var pathToAdd in pathsToAdd) + pathStack.Push(pathToAdd); + + path = Constants.UserEnvironmentPaths.RecycleBinPath; + } + else if (!string.IsNullOrEmpty(pathRoot)) { var rootPathList = App.QuickAccessManager.Model.PinnedFolders.Select(NormalizePath) .Concat(CloudDrivesManager.Drives.Select(x => NormalizePath(x.Path))).ToList()