Skip to content

Commit 5db3b84

Browse files
authored
Feature: Focus existing tab when opening location from external process (#16011)
1 parent fd4a670 commit 5db3b84

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/Files.App/MainWindow.xaml.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,17 @@ async Task PerformNavigationAsync(string payload, string selectItem = null)
258258
// Bring to foreground (#14730)
259259
Win32Helper.BringToForegroundEx(new(WindowHandle));
260260

261-
await NavigationHelpers.AddNewTabByParamAsync(typeof(ShellPanesPage), paneNavigationArgs);
261+
var existingTabIndex = MainPageViewModel.AppInstances
262+
.Select((tabItem, idx) => new { tabItem, idx })
263+
.FirstOrDefault(x =>
264+
x.tabItem.NavigationParameter.NavigationParameter is PaneNavigationArguments paneArgs &&
265+
(paneNavigationArgs.LeftPaneNavPathParam == paneArgs.LeftPaneNavPathParam ||
266+
paneNavigationArgs.LeftPaneNavPathParam == paneArgs.RightPaneNavPathParam))?.idx ?? -1;
267+
268+
if (existingTabIndex >= 0)
269+
App.AppModel.TabStripSelectedIndex = existingTabIndex;
270+
else
271+
await NavigationHelpers.AddNewTabByParamAsync(typeof(ShellPanesPage), paneNavigationArgs);
262272
}
263273
else
264274
rootFrame.Navigate(typeof(MainPage), paneNavigationArgs, new SuppressNavigationTransitionInfo());

0 commit comments

Comments
 (0)