Skip to content

Commit 2f8c51e

Browse files
authored
Standardize on Tab::Close for closing tabs (#19656)
This makes it possible to subscribe to `Close` events.
1 parent a331c42 commit 2f8c51e

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

src/cascadia/TerminalApp/Tab.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -933,6 +933,13 @@ namespace winrt::TerminalApp::implementation
933933
return res;
934934
}
935935

936+
void Tab::Close()
937+
{
938+
ASSERT_UI_THREAD();
939+
940+
Closed.raise(nullptr, nullptr);
941+
}
942+
936943
// Method Description:
937944
// - Prepares this tab for being removed from the UI hierarchy by shutting down all active connections.
938945
void Tab::Shutdown()

src/cascadia/TerminalApp/Tab.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ namespace winrt::TerminalApp::implementation
6161
void UpdateSettings(const winrt::Microsoft::Terminal::Settings::Model::CascadiaSettings& settings);
6262
void UpdateTitle();
6363

64+
void Close();
6465
void Shutdown();
6566
void ClosePane();
6667

src/cascadia/TerminalApp/Tab.idl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ namespace TerminalApp
2222
UInt32 TabViewNumTabs;
2323

2424
void Focus(Windows.UI.Xaml.FocusState focusState);
25+
void Close();
2526
void Shutdown();
2627

2728
void SetDispatch(ShortcutActionDispatch dispatch);

src/cascadia/TerminalApp/TabManagement.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -411,13 +411,11 @@ namespace winrt::TerminalApp::implementation
411411
auto actions = t->BuildStartupActions(BuildStartupKind::None);
412412
_AddPreviouslyClosedPaneOrTab(std::move(actions));
413413

414-
_RemoveTab(tab);
414+
tab.Close();
415415
}
416416

417-
// Method Description:
418-
// - Removes the tab (both TerminalControl and XAML)
419-
// Arguments:
420-
// - tab: the tab to remove
417+
// Removes the tab (both TerminalControl and XAML).
418+
// NOTE: Don't call this directly, but rather `tab.Close()`.
421419
void TerminalPage::_RemoveTab(const winrt::TerminalApp::Tab& tab)
422420
{
423421
uint32_t tabIndex{};

0 commit comments

Comments
 (0)