From f8dcc28ac4b015c11c212ac74dd4b2934d28c115 Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Wed, 22 May 2024 12:27:06 -0400 Subject: [PATCH 1/2] Update AddressToolbarViewModel.cs --- .../ViewModels/UserControls/AddressToolbarViewModel.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Files.App/ViewModels/UserControls/AddressToolbarViewModel.cs b/src/Files.App/ViewModels/UserControls/AddressToolbarViewModel.cs index f0ff6e2c3876..bbac360bc4e4 100644 --- a/src/Files.App/ViewModels/UserControls/AddressToolbarViewModel.cs +++ b/src/Files.App/ViewModels/UserControls/AddressToolbarViewModel.cs @@ -688,6 +688,10 @@ public async Task SetPathBoxDropDownFlyoutAsync(MenuFlyout flyout, PathBoxItem p private static string NormalizePathInput(string currentInput, bool isFtp) { + // Check if input is a command and not a path + if (currentInput.Length > 1 && currentInput.ElementAt(1) != ':') + return currentInput; + if (currentInput.Contains('/') && !isFtp) currentInput = currentInput.Replace("/", "\\", StringComparison.Ordinal); From 86f4a8c9eb68bd27669d6a90b9c298f6afdddffb Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Wed, 22 May 2024 15:44:14 -0400 Subject: [PATCH 2/2] Update AddressToolbarViewModel.cs --- .../UserControls/AddressToolbarViewModel.cs | 32 ++++++++----------- 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/src/Files.App/ViewModels/UserControls/AddressToolbarViewModel.cs b/src/Files.App/ViewModels/UserControls/AddressToolbarViewModel.cs index bbac360bc4e4..3ccae1d67942 100644 --- a/src/Files.App/ViewModels/UserControls/AddressToolbarViewModel.cs +++ b/src/Files.App/ViewModels/UserControls/AddressToolbarViewModel.cs @@ -688,10 +688,6 @@ public async Task SetPathBoxDropDownFlyoutAsync(MenuFlyout flyout, PathBoxItem p private static string NormalizePathInput(string currentInput, bool isFtp) { - // Check if input is a command and not a path - if (currentInput.Length > 1 && currentInput.ElementAt(1) != ':') - return currentInput; - if (currentInput.Contains('/') && !isFtp) currentInput = currentInput.Replace("/", "\\", StringComparison.Ordinal); @@ -724,30 +720,30 @@ await DialogDisplayHelper.ShowDialogAsync("CommandNotExecutable".GetLocalizedRes var isFtp = FtpHelpers.IsFtpPath(currentInput); - currentInput = NormalizePathInput(currentInput, isFtp); + var normalizedInput = NormalizePathInput(currentInput, isFtp); - if (currentSelectedPath == currentInput || string.IsNullOrWhiteSpace(currentInput)) + if (currentSelectedPath == normalizedInput || string.IsNullOrWhiteSpace(normalizedInput)) return; - if (currentInput != shellPage.FilesystemViewModel.WorkingDirectory || shellPage.CurrentPageType == typeof(HomePage)) + if (normalizedInput != shellPage.FilesystemViewModel.WorkingDirectory || shellPage.CurrentPageType == typeof(HomePage)) { - if (currentInput.Equals("Home", StringComparison.OrdinalIgnoreCase) || currentInput.Equals("Home".GetLocalizedResource(), StringComparison.OrdinalIgnoreCase)) + if (normalizedInput.Equals("Home", StringComparison.OrdinalIgnoreCase) || normalizedInput.Equals("Home".GetLocalizedResource(), StringComparison.OrdinalIgnoreCase)) { SavePathToHistory("Home"); shellPage.NavigateHome(); } else { - currentInput = StorageFileExtensions.GetResolvedPath(currentInput, isFtp); - if (currentSelectedPath == currentInput) + normalizedInput = StorageFileExtensions.GetResolvedPath(normalizedInput, isFtp); + if (currentSelectedPath == normalizedInput) return; - var item = await FilesystemTasks.Wrap(() => DriveHelpers.GetRootFromPathAsync(currentInput)); + var item = await FilesystemTasks.Wrap(() => DriveHelpers.GetRootFromPathAsync(normalizedInput)); - var resFolder = await FilesystemTasks.Wrap(() => StorageFileExtensions.DangerousGetFolderWithPathFromPathAsync(currentInput, item)); - if (resFolder || FolderHelpers.CheckFolderAccessWithWin32(currentInput)) + var resFolder = await FilesystemTasks.Wrap(() => StorageFileExtensions.DangerousGetFolderWithPathFromPathAsync(normalizedInput, item)); + if (resFolder || FolderHelpers.CheckFolderAccessWithWin32(normalizedInput)) { - var matchingDrive = drivesViewModel.Drives.Cast().FirstOrDefault(x => PathNormalization.NormalizePath(currentInput).StartsWith(PathNormalization.NormalizePath(x.Path), StringComparison.Ordinal)); + var matchingDrive = drivesViewModel.Drives.Cast().FirstOrDefault(x => PathNormalization.NormalizePath(normalizedInput).StartsWith(PathNormalization.NormalizePath(x.Path), StringComparison.Ordinal)); if (matchingDrive is not null && matchingDrive.Type == Data.Items.DriveType.CDRom && matchingDrive.MaxSpace == ByteSizeLib.ByteSize.FromBytes(0)) { bool ejectButton = await DialogDisplayHelper.ShowDialogAsync("InsertDiscDialog/Title".GetLocalizedResource(), string.Format("InsertDiscDialog/Text".GetLocalizedResource(), matchingDrive.Path), "InsertDiscDialog/OpenDriveButton".GetLocalizedResource(), "Close".GetLocalizedResource()); @@ -758,18 +754,18 @@ await DialogDisplayHelper.ShowDialogAsync("CommandNotExecutable".GetLocalizedRes } return; } - var pathToNavigate = resFolder.Result?.Path ?? currentInput; + var pathToNavigate = resFolder.Result?.Path ?? normalizedInput; SavePathToHistory(pathToNavigate); shellPage.NavigateToPath(pathToNavigate); } else if (isFtp) { - SavePathToHistory(currentInput); - shellPage.NavigateToPath(currentInput); + SavePathToHistory(normalizedInput); + shellPage.NavigateToPath(normalizedInput); } else // Not a folder or inaccessible { - var resFile = await FilesystemTasks.Wrap(() => StorageFileExtensions.DangerousGetFileWithPathFromPathAsync(currentInput, item)); + var resFile = await FilesystemTasks.Wrap(() => StorageFileExtensions.DangerousGetFileWithPathFromPathAsync(normalizedInput, item)); if (resFile) { var pathToInvoke = resFile.Result.Path;