diff --git a/doc/cascadia/profiles.schema.json b/doc/cascadia/profiles.schema.json
index b8e6c9ab401..59fadf3e6ee 100644
--- a/doc/cascadia/profiles.schema.json
+++ b/doc/cascadia/profiles.schema.json
@@ -2658,6 +2658,11 @@
"description": "When set to \"true\" closing a window with multiple tabs open will require confirmation. When set to \"false\", the confirmation dialog will not appear.",
"type": "boolean"
},
+ "warning.confirmCloseAllPanes": {
+ "default": true,
+ "description": "When set to \"true\" closing a tab with multiple panes open will require confirmation. When set to \"false\", the confirmation dialog will not appear.",
+ "type": "boolean"
+ },
"useTabSwitcher": {
"description": "[Deprecated] Replaced with the \"tabSwitcherMode\" setting.",
"default": true,
diff --git a/src/cascadia/TerminalApp/Resources/en-US/Resources.resw b/src/cascadia/TerminalApp/Resources/en-US/Resources.resw
index 81ca7d51f83..ece408ff174 100644
--- a/src/cascadia/TerminalApp/Resources/en-US/Resources.resw
+++ b/src/cascadia/TerminalApp/Resources/en-US/Resources.resw
@@ -526,6 +526,18 @@
You are about to close a read-only terminal. Do you wish to continue?
+
+ Cancel
+
+
+ This tab has multiple panes. Do you want to close all of them?
+
+
+ Close tab
+
+
+ Warning
+
Cancel
diff --git a/src/cascadia/TerminalApp/TabManagement.cpp b/src/cascadia/TerminalApp/TabManagement.cpp
index 21e31fb6dd3..5b7cc82cc63 100644
--- a/src/cascadia/TerminalApp/TabManagement.cpp
+++ b/src/cascadia/TerminalApp/TabManagement.cpp
@@ -414,6 +414,21 @@ namespace winrt::TerminalApp::implementation
}
auto t = winrt::get_self(tab);
+ if (t->GetLeafPaneCount() > 1 && _settings.GlobalSettings().ConfirmCloseAllPanes())
+ {
+ const auto weak = get_weak();
+
+ auto warningResult = co_await _ShowCloseTabWarningDialog();
+
+ strong = weak.get();
+
+ // If the user didn't explicitly click on close tab - leave
+ if (!strong || warningResult != ContentDialogResult::Primary)
+ {
+ co_return;
+ }
+ }
+
auto actions = t->BuildStartupActions(BuildStartupKind::None);
_AddPreviouslyClosedPaneOrTab(std::move(actions));
diff --git a/src/cascadia/TerminalApp/TerminalPage.cpp b/src/cascadia/TerminalApp/TerminalPage.cpp
index e98de6b9957..2f5ee298a43 100644
--- a/src/cascadia/TerminalApp/TerminalPage.cpp
+++ b/src/cascadia/TerminalApp/TerminalPage.cpp
@@ -913,6 +913,17 @@ namespace winrt::TerminalApp::implementation
return _ShowDialogHelper(L"CloseReadOnlyDialog");
}
+ // Method Description:
+ // - Displays a dialog to warn the user that they are about to close a tab with
+ // multiple panes open. Once the user clicks the "Close tab" button, close the tab.
+ // If "Cancel" is clicked, the dialog will close.
+ // - Only one dialog can be visible at a time. If another dialog is visible
+ // when this is called, nothing happens. See _ShowDialog for details
+ winrt::Windows::Foundation::IAsyncOperation TerminalPage::_ShowCloseTabWarningDialog()
+ {
+ return _ShowDialogHelper(L"CloseTabWarningDialog");
+ }
+
// Method Description:
// - Displays a dialog to warn the user about the fact that the text that
// they are trying to paste contains the "new line" character which can
diff --git a/src/cascadia/TerminalApp/TerminalPage.h b/src/cascadia/TerminalApp/TerminalPage.h
index 4b48cc0e9d9..b9467af2a29 100644
--- a/src/cascadia/TerminalApp/TerminalPage.h
+++ b/src/cascadia/TerminalApp/TerminalPage.h
@@ -304,6 +304,7 @@ namespace winrt::TerminalApp::implementation
winrt::Windows::Foundation::IAsyncOperation _ShowQuitDialog();
winrt::Windows::Foundation::IAsyncOperation _ShowCloseWarningDialog();
winrt::Windows::Foundation::IAsyncOperation _ShowCloseReadOnlyDialog();
+ winrt::Windows::Foundation::IAsyncOperation _ShowCloseTabWarningDialog();
winrt::Windows::Foundation::IAsyncOperation _ShowMultiLinePasteWarningDialog();
winrt::Windows::Foundation::IAsyncOperation _ShowLargePasteWarningDialog();
diff --git a/src/cascadia/TerminalApp/TerminalPage.xaml b/src/cascadia/TerminalApp/TerminalPage.xaml
index 40e3b838c37..8b4fff94c64 100644
--- a/src/cascadia/TerminalApp/TerminalPage.xaml
+++ b/src/cascadia/TerminalApp/TerminalPage.xaml
@@ -104,6 +104,12 @@
x:Load="False"
DefaultButton="Close" />
+
+