mirror of
https://github.com/microsoft/terminal.git
synced 2025-12-10 18:43:54 -06:00
Provide workaround for _GetFocusedTabIndex (#1117)
Use tabview.SelectedIndex for setting focus tab References Closes #1100, Closes #1039, Closes #1074
This commit is contained in:
parent
880272c748
commit
d51ce7021c
@ -631,6 +631,8 @@ namespace winrt::TerminalApp::implementation
|
||||
|
||||
void App::_SetFocusedTabIndex(int tabIndex)
|
||||
{
|
||||
// GH#1117: This is a workaround because _tabView.SelectedIndex(tabIndex)
|
||||
// sometimes set focus to an incorrect tab after removing some tabs
|
||||
auto tab = _tabs.at(tabIndex);
|
||||
_tabView.Dispatcher().RunAsync(CoreDispatcherPriority::Normal, [tab, this](){
|
||||
auto tabViewItem = tab->GetTabViewItem();
|
||||
@ -815,7 +817,14 @@ namespace winrt::TerminalApp::implementation
|
||||
// - the index of the currently focused tab if there is one, else -1
|
||||
int App::_GetFocusedTabIndex() const
|
||||
{
|
||||
return _tabView.SelectedIndex();
|
||||
// GH#1117: This is a workaround because _tabView.SelectedIndex()
|
||||
// sometimes return incorrect result after removing some tabs
|
||||
uint32_t focusedIndex;
|
||||
if (_tabView.Items().IndexOf(_tabView.SelectedItem(), focusedIndex))
|
||||
{
|
||||
return focusedIndex;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void App::_OpenSettings()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user