Closing the tab shifts focus to the right (#767)

* On closing the tab - the focus is shifted to the right.
This commit is contained in:
Juris Bogusevs 2019-05-23 14:24:40 +01:00 committed by Mike Griese
parent bbbd3e0323
commit 5ec7c0325e

View file

@ -874,18 +874,26 @@ namespace winrt::TerminalApp::implementation
}
uint32_t tabIndexFromControl = 0;
_tabView.Items().IndexOf(tabViewItem, tabIndexFromControl);
if (tabIndexFromControl == _GetFocusedTabIndex())
{
_tabView.SelectedIndex((tabIndexFromControl > 0) ? tabIndexFromControl - 1 : 1);
}
auto focusedTabIndex = _GetFocusedTabIndex();
// Removing the tab from the collection will destroy its control and disconnect its connection.
_tabs.erase(_tabs.begin() + tabIndexFromControl);
_tabView.Items().RemoveAt(tabIndexFromControl);
// ensure tabs and focus is sync
_tabView.SelectedIndex(tabIndexFromControl > 0 ? tabIndexFromControl - 1 : 0);
if (tabIndexFromControl == focusedTabIndex)
{
if (focusedTabIndex >= _tabs.size())
{
focusedTabIndex = _tabs.size() - 1;
}
if (focusedTabIndex < 0)
{
focusedTabIndex = 0;
}
_SelectTab(focusedTabIndex);
}
}
// Method Description: