diff --git a/src/Files.App/Program.cs b/src/Files.App/Program.cs index c156aff16d73..513a0a0eeaba 100644 --- a/src/Files.App/Program.cs +++ b/src/Files.App/Program.cs @@ -42,7 +42,7 @@ private static void Main() WinRT.ComWrappersSupport.InitializeComWrappers(); var proc = Process.GetCurrentProcess(); - var alwaysOpenNewInstance = ApplicationData.Current.LocalSettings.Values.Get("AlwaysOpenANewInstance", false); + var OpenTabInExistingInstance = ApplicationData.Current.LocalSettings.Values.Get("OpenTabInExistingInstance", true); var activatedArgs = AppInstance.GetCurrent().GetActivatedEventArgs(); if (activatedArgs.Data is ICommandLineActivatedEventArgs cmdLineArgs) @@ -76,7 +76,7 @@ private static void Main() // Always open a new instance for OpenDialog, never open new instance for "-Tag" command if (parsedCommands is null || !parsedCommands.Any(x => x.Type == ParsedCommandType.OutputPath) && - (!alwaysOpenNewInstance || parsedCommands.Any(x => x.Type == ParsedCommandType.TagFiles))) + (OpenTabInExistingInstance || parsedCommands.Any(x => x.Type == ParsedCommandType.TagFiles))) { var activePid = ApplicationData.Current.LocalSettings.Values.Get("INSTANCE_ACTIVE", -1); var instance = AppInstance.FindOrRegisterForKey(activePid.ToString()); @@ -102,7 +102,7 @@ private static void Main() } } - if (!alwaysOpenNewInstance) + if (OpenTabInExistingInstance) { if (activatedArgs.Data is ILaunchActivatedEventArgs launchArgs) { @@ -117,7 +117,8 @@ private static void Main() else if (activatedArgs.Data is IProtocolActivatedEventArgs protocolArgs) { var parsedArgs = protocolArgs.Uri.Query.TrimStart('?').Split('='); - if (parsedArgs.Length == 2 && parsedArgs[0] == "cmd") // Treat as command line launch + if ((parsedArgs.Length == 2 && parsedArgs[0] == "cmd") || + parsedArgs.Length == 1) // Treat Win+E & Open file location as command line launch { var activePid = ApplicationData.Current.LocalSettings.Values.Get("INSTANCE_ACTIVE", -1); var instance = AppInstance.FindOrRegisterForKey(activePid.ToString()); diff --git a/src/Files.App/Services/Settings/GeneralSettingsService.cs b/src/Files.App/Services/Settings/GeneralSettingsService.cs index 70068317a42d..500104296415 100644 --- a/src/Files.App/Services/Settings/GeneralSettingsService.cs +++ b/src/Files.App/Services/Settings/GeneralSettingsService.cs @@ -43,9 +43,9 @@ public bool OpenNewTabOnStartup set => Set(value); } - public bool AlwaysOpenNewInstance + public bool OpenTabInExistingInstance { - get => Get(false); + get => Get(true); set => Set(value); } @@ -241,7 +241,7 @@ protected override void RaiseOnSettingChangedEvent(object sender, SettingChanged case nameof(OpenSpecificPageOnStartup): case nameof(ContinueLastSessionOnStartUp): case nameof(OpenNewTabOnStartup): - case nameof(AlwaysOpenNewInstance): + case nameof(OpenTabInExistingInstance): case nameof(AlwaysOpenDualPaneInNewTab): case nameof(ShowQuickAccessWidget): case nameof(ShowRecentFilesWidget): diff --git a/src/Files.App/Strings/en-US/Resources.resw b/src/Files.App/Strings/en-US/Resources.resw index 2658f5805254..ddb3791ccaf6 100644 --- a/src/Files.App/Strings/en-US/Resources.resw +++ b/src/Files.App/Strings/en-US/Resources.resw @@ -1815,8 +1815,8 @@ Restore default - - Open new instance when opening directories from the taskbar jumplist + + Open tab in existing instance when opening Files from another app Startup settings diff --git a/src/Files.App/ViewModels/Settings/GeneralViewModel.cs b/src/Files.App/ViewModels/Settings/GeneralViewModel.cs index 3e0aed126b8c..f3f0246ede54 100644 --- a/src/Files.App/ViewModels/Settings/GeneralViewModel.cs +++ b/src/Files.App/ViewModels/Settings/GeneralViewModel.cs @@ -222,17 +222,17 @@ public ReadOnlyCollection AddFlyoutItemsSource set => SetProperty(ref addFlyoutItemsSource, value); } - public bool AlwaysOpenANewInstance + public bool OpenTabInExistingInstance { - get => UserSettingsService.GeneralSettingsService.AlwaysOpenNewInstance; + get => UserSettingsService.GeneralSettingsService.OpenTabInExistingInstance; set { - if (value != UserSettingsService.GeneralSettingsService.AlwaysOpenNewInstance) + if (value != UserSettingsService.GeneralSettingsService.OpenTabInExistingInstance) { - UserSettingsService.GeneralSettingsService.AlwaysOpenNewInstance = value; + UserSettingsService.GeneralSettingsService.OpenTabInExistingInstance = value; // Needed in Program.cs - ApplicationData.Current.LocalSettings.Values["AlwaysOpenANewInstance"] = value; + ApplicationData.Current.LocalSettings.Values["OpenTabInExistingInstance"] = value; OnPropertyChanged(); } diff --git a/src/Files.App/Views/Settings/GeneralPage.xaml b/src/Files.App/Views/Settings/GeneralPage.xaml index 4dc9b32b318d..f338209ad8d9 100644 --- a/src/Files.App/Views/Settings/GeneralPage.xaml +++ b/src/Files.App/Views/Settings/GeneralPage.xaml @@ -190,10 +190,10 @@ - + diff --git a/src/Files.Core/Services/Settings/IGeneralSettingsService.cs b/src/Files.Core/Services/Settings/IGeneralSettingsService.cs index 61903a29d441..a6e0e5ae626d 100644 --- a/src/Files.Core/Services/Settings/IGeneralSettingsService.cs +++ b/src/Files.Core/Services/Settings/IGeneralSettingsService.cs @@ -35,9 +35,9 @@ public interface IGeneralSettingsService : IBaseSettingsService, INotifyProperty bool OpenNewTabOnStartup { get; set; } /// - /// Gets or sets a value indicating whether or not opening the app from the jumplist should open the directory in a new instance. + /// Gets or sets a value indicating whether or not opening Files from another app should open a tab in the existing instance. /// - bool AlwaysOpenNewInstance { get; set; } + bool OpenTabInExistingInstance { get; set; } /// /// A list containing all paths to open at startup.