Skip to content

Commit

Permalink
[silmarillion] Pull DetachTab into a method
Browse files Browse the repository at this point in the history
  • Loading branch information
zadjii-msft committed Feb 6, 2023
1 parent c282797 commit ba7b5ae
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
26 changes: 15 additions & 11 deletions src/cascadia/TerminalApp/TerminalPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2031,6 +2031,20 @@ namespace winrt::TerminalApp::implementation
return true;
}

void TerminalPage::_DetachTab(const winrt::com_ptr<TerminalTab>& terminalTab)
{
// Collect all the content we're about to detach.
if (const auto rootPane = terminalTab->GetRootPane())
{
rootPane->WalkTree([&](auto p) {
if (const auto& control{ p->GetTerminalControl() })
{
_manager.Detach(control.ContentGuid());
}
});
}
}

bool TerminalPage::_MoveTab(MoveTabArgs args)
{
const auto windowId{ args.Window() };
Expand All @@ -2039,17 +2053,7 @@ namespace winrt::TerminalApp::implementation
if (const auto terminalTab{ _GetFocusedTabImpl() })
{
auto startupActions = terminalTab->BuildStartupActions(true);

// Collect all the content we're about to detach.
if (const auto rootPane = terminalTab->GetRootPane())
{
rootPane->WalkTree([&](auto p) {
if (const auto& control{ p->GetTerminalControl() })
{
_manager.Detach(control.ContentGuid());
}
});
}
_DetachTab(terminalTab);

auto winRtActions{ winrt::single_threaded_vector<ActionAndArgs>(std::move(startupActions)) };
// Json::Value json{ Json::objectValue };
Expand Down
1 change: 1 addition & 0 deletions src/cascadia/TerminalApp/TerminalPage.h
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,7 @@ namespace winrt::TerminalApp::implementation
void _onTabDragStarting(winrt::Microsoft::UI::Xaml::Controls::TabView sender, winrt::Microsoft::UI::Xaml::Controls::TabViewTabDragStartingEventArgs e);
void _onTabStripDragOver(winrt::Windows::Foundation::IInspectable sender, winrt::Windows::UI::Xaml::DragEventArgs e);
winrt::fire_and_forget _onTabStripDrop(winrt::Windows::Foundation::IInspectable sender, winrt::Windows::UI::Xaml::DragEventArgs e);
void _DetachTab(const winrt::com_ptr<TerminalTab>& terminalTab);

#pragma region ActionHandlers
// These are all defined in AppActionHandlers.cpp
Expand Down

0 comments on commit ba7b5ae

Please sign in to comment.