Skip to content

Commit

Permalink
changing the name to be a bit more descriptive
Browse files Browse the repository at this point in the history
  • Loading branch information
leonMSFT committed Sep 30, 2020
1 parent 3fdb0f1 commit cb91b2a
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 24 deletions.
8 changes: 4 additions & 4 deletions src/cascadia/LocalTests_TerminalApp/TabTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ namespace TerminalAppLocalTests
// In the real app, this isn't a problem, but doesn't happen
// reliably in the unit tests.
Log::Comment(L"Ensure we set the first tab as the selected one.");
auto tab{ page->_GetStrongTabImpl(0) };
auto tab{ page->_GetTerminalTabImpl(0) };
page->_tabView.SelectedItem(tab->GetTabViewItem());
page->_UpdatedSelectedTab(0);
});
Expand Down Expand Up @@ -469,7 +469,7 @@ namespace TerminalAppLocalTests

result = RunOnUIThread([&page]() {
VERIFY_ARE_EQUAL(1u, page->_tabs.Size());
auto tab = page->_GetStrongTabImpl(0);
auto tab = page->_GetTerminalTabImpl(0);
VERIFY_ARE_EQUAL(1, tab->GetLeafPaneCount());
});
VERIFY_SUCCEEDED(result);
Expand All @@ -479,7 +479,7 @@ namespace TerminalAppLocalTests
page->_SplitPane(SplitState::Automatic, SplitType::Duplicate, nullptr);

VERIFY_ARE_EQUAL(1u, page->_tabs.Size());
auto tab = page->_GetStrongTabImpl(0);
auto tab = page->_GetTerminalTabImpl(0);
VERIFY_ARE_EQUAL(2, tab->GetLeafPaneCount());
});
VERIFY_SUCCEEDED(result);
Expand All @@ -497,7 +497,7 @@ namespace TerminalAppLocalTests
page->_SplitPane(SplitState::Automatic, SplitType::Duplicate, nullptr);

VERIFY_ARE_EQUAL(1u, page->_tabs.Size());
auto tab = page->_GetStrongTabImpl(0);
auto tab = page->_GetTerminalTabImpl(0);
VERIFY_ARE_EQUAL(2,
tab->GetLeafPaneCount(),
L"We should gracefully do nothing here - the profile no longer exists.");
Expand Down
47 changes: 29 additions & 18 deletions src/cascadia/TerminalApp/TerminalPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1015,7 +1015,7 @@ namespace winrt::TerminalApp::implementation
{
if (auto index{ _GetFocusedTabIndex() })
{
if (auto terminalTab = _GetStrongTabImpl(*index))
if (auto terminalTab = _GetTerminalTabImpl(*index))
{
try
{
Expand Down Expand Up @@ -1297,7 +1297,7 @@ namespace winrt::TerminalApp::implementation
{
if (auto index{ _GetFocusedTabIndex() })
{
if (auto terminalTab = _GetStrongTabImpl(*index))
if (auto terminalTab = _GetTerminalTabImpl(*index))
{
_UnZoomIfNeeded();
terminalTab->NavigateFocus(direction);
Expand All @@ -1309,7 +1309,7 @@ namespace winrt::TerminalApp::implementation
{
if (auto index{ _GetFocusedTabIndex() })
{
if (auto terminalTab = _GetStrongTabImpl(*index))
if (auto terminalTab = _GetTerminalTabImpl(*index))
{
return terminalTab->GetActiveTerminalControl();
}
Expand Down Expand Up @@ -1389,7 +1389,7 @@ namespace winrt::TerminalApp::implementation
{
if (auto index{ _GetFocusedTabIndex() })
{
if (auto terminalTab = _GetStrongTabImpl(*index))
if (auto terminalTab = _GetTerminalTabImpl(*index))
{
_UnZoomIfNeeded();
terminalTab->ClosePane();
Expand Down Expand Up @@ -1433,7 +1433,7 @@ namespace winrt::TerminalApp::implementation
{
if (auto index{ _GetFocusedTabIndex() })
{
if (auto terminalTab = _GetStrongTabImpl(*index))
if (auto terminalTab = _GetTerminalTabImpl(*index))
{
terminalTab->Scroll(delta);
}
Expand Down Expand Up @@ -1469,7 +1469,7 @@ namespace winrt::TerminalApp::implementation
return;
}

auto focusedTab = _GetStrongTabImpl(*indexOpt);
auto focusedTab = _GetTerminalTabImpl(*indexOpt);

// Do nothing if the focused tab isn't a TerminalTab
if (!focusedTab)
Expand Down Expand Up @@ -1552,7 +1552,7 @@ namespace winrt::TerminalApp::implementation
{
if (auto index{ _GetFocusedTabIndex() })
{
if (auto terminalTab = _GetStrongTabImpl(*index))
if (auto terminalTab = _GetTerminalTabImpl(*index))
{
_UnZoomIfNeeded();
terminalTab->ResizePane(direction);
Expand All @@ -1577,7 +1577,7 @@ namespace winrt::TerminalApp::implementation
return;
}

if (auto terminalTab = _GetStrongTabImpl(*indexOpt))
if (auto terminalTab = _GetTerminalTabImpl(*indexOpt))
{
delta = std::clamp(delta, -1, 1);
const auto control = _GetActiveControl();
Expand Down Expand Up @@ -1694,7 +1694,7 @@ namespace winrt::TerminalApp::implementation
{
if (auto index{ _GetFocusedTabIndex() })
{
if (auto terminalTab = _GetStrongTabImpl(*index))
if (auto terminalTab = _GetTerminalTabImpl(*index))
{
return terminalTab->CalcSnappedDimension(widthOrHeight, dimension);
}
Expand Down Expand Up @@ -2591,12 +2591,14 @@ namespace winrt::TerminalApp::implementation
}

// Method Description:
// - Returns a com_ptr to the implementation type of the tab at the given index
// - Returns a com_ptr to the implementation type of a TerminalTab at the given index.
// If the tab is not a TerminalTab, returns nullptr.
// Arguments:
// - index: an unsigned integer index to a tab in _tabs
// Return Value:
// - a com_ptr to the implementation type of the Tab
winrt::com_ptr<TerminalTab> TerminalPage::_GetStrongTabImpl(const uint32_t index) const
// - If the tab is a TerminalTab, a com_ptr to the implementation type.
// If the tab is not a TerminalTab, nullptr
winrt::com_ptr<TerminalTab> TerminalPage::_GetTerminalTabImpl(const uint32_t index) const
{
if (auto tab = _tabs.GetAt(index).try_as<TerminalApp::TerminalTab>())
{
Expand All @@ -2611,16 +2613,25 @@ namespace winrt::TerminalApp::implementation
}

// Method Description:
// - Returns a com_ptr to the implementation type of the given projected Tab
// - Returns a com_ptr to the implementation type of the given tab if it's a TerminalTab.
// If the tab is not a TerminalTab, returns nullptr.
// Arguments:
// - tab: the projected type of a Tab
// Return Value:
// - a com_ptr to the implementation type of the Tab
winrt::com_ptr<TerminalTab> TerminalPage::_GetStrongTabImpl(const ::winrt::TerminalApp::TerminalTab& tab) const
// - If the tab is a TerminalTab, a com_ptr to the implementation type.
// If the tab is not a TerminalTab, nullptr
winrt::com_ptr<TerminalTab> TerminalPage::_GetTerminalTabImpl(const ITab& tab) const
{
winrt::com_ptr<TerminalTab> tabImpl;
tabImpl.copy_from(winrt::get_self<TerminalTab>(tab));
return tabImpl;
if (auto terminalTab = tab.try_as<TerminalApp::TerminalTab>())
{
winrt::com_ptr<TerminalTab> tabImpl;
tabImpl.copy_from(winrt::get_self<TerminalTab>(terminalTab));
return tabImpl;
}
else
{
return nullptr;
}
}

// -------------------------------- WinRT Events ---------------------------------
Expand Down
4 changes: 2 additions & 2 deletions src/cascadia/TerminalApp/TerminalPage.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ namespace winrt::TerminalApp::implementation
TerminalApp::CascadiaSettings _settings{ nullptr };

Windows::Foundation::Collections::IObservableVector<TerminalApp::ITab> _tabs;
winrt::com_ptr<TerminalTab> _GetStrongTabImpl(const uint32_t index) const;
winrt::com_ptr<TerminalTab> _GetStrongTabImpl(const ::winrt::TerminalApp::TerminalTab& tab) const;
winrt::com_ptr<TerminalTab> _GetTerminalTabImpl(const uint32_t index) const;
winrt::com_ptr<TerminalTab> _GetTerminalTabImpl(const ITab& tab) const;
void _UpdateTabIndices();

bool _isInFocusMode{ false };
Expand Down

1 comment on commit cb91b2a

@github-actions

This comment was marked as resolved.

Please sign in to comment.