From 6b602e70c5c21e8684d729c601ce976acb2e0ef1 Mon Sep 17 00:00:00 2001 From: leo Date: Thu, 3 Jun 2021 12:06:53 +0800 Subject: [PATCH] optimize: move to previous one when the last tab is closed --- src/Views/Widgets/PageTabBar.xaml.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Views/Widgets/PageTabBar.xaml.cs b/src/Views/Widgets/PageTabBar.xaml.cs index 1774d21c..79caed87 100644 --- a/src/Views/Widgets/PageTabBar.xaml.cs +++ b/src/Views/Widgets/PageTabBar.xaml.cs @@ -127,7 +127,8 @@ namespace SourceGit.Views.Widgets { Tabs.Remove(curTab); RaiseEvent(new TabEventArgs(TabClosedEvent, this, curTab.Id)); - var next = Tabs[idx % Tabs.Count]; + var last = Tabs.Count - 1; + var next = idx > last ? Tabs[last] : Tabs[idx]; container.SelectedItem = next; RaiseEvent(new TabEventArgs(TabSelectedEvent, this, next.Id)); } @@ -171,7 +172,8 @@ namespace SourceGit.Views.Widgets { var idx = Tabs.IndexOf(tab); Tabs.Remove(tab); - var next = Tabs[idx % Tabs.Count]; + var last = Tabs.Count - 1; + var next = idx > last ? Tabs[last] : Tabs[idx]; container.SelectedItem = next; RaiseEvent(new TabEventArgs(TabSelectedEvent, this, next.Id)); } else {