Skip to content

Commit

Permalink
Feature: Focus existing tab when opening location from external proce…
Browse files Browse the repository at this point in the history
  • Loading branch information
yaira2 authored Aug 18, 2024
1 parent fd4a670 commit 5db3b84
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/Files.App/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,17 @@ async Task PerformNavigationAsync(string payload, string selectItem = null)
// Bring to foreground (#14730)
Win32Helper.BringToForegroundEx(new(WindowHandle));

await NavigationHelpers.AddNewTabByParamAsync(typeof(ShellPanesPage), paneNavigationArgs);
var existingTabIndex = MainPageViewModel.AppInstances
.Select((tabItem, idx) => new { tabItem, idx })
.FirstOrDefault(x =>
x.tabItem.NavigationParameter.NavigationParameter is PaneNavigationArguments paneArgs &&
(paneNavigationArgs.LeftPaneNavPathParam == paneArgs.LeftPaneNavPathParam ||
paneNavigationArgs.LeftPaneNavPathParam == paneArgs.RightPaneNavPathParam))?.idx ?? -1;

if (existingTabIndex >= 0)
App.AppModel.TabStripSelectedIndex = existingTabIndex;
else
await NavigationHelpers.AddNewTabByParamAsync(typeof(ShellPanesPage), paneNavigationArgs);
}
else
rootFrame.Navigate(typeof(MainPage), paneNavigationArgs, new SuppressNavigationTransitionInfo());
Expand Down

0 comments on commit 5db3b84

Please sign in to comment.