Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions doc/cascadia/profiles.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
12 changes: 12 additions & 0 deletions src/cascadia/TerminalApp/Resources/en-US/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,18 @@
<data name="CloseReadOnlyDialog.Content" xml:space="preserve">
<value>You are about to close a read-only terminal. Do you wish to continue?</value>
</data>
<data name="CloseTabWarningDialog.CloseButtonText" xml:space="preserve">
<value>Cancel</value>
</data>
<data name="CloseTabWarningDialog.Content" xml:space="preserve">
<value>This tab has multiple panes. Do you want to close all of them?</value>
</data>
<data name="CloseTabWarningDialog.PrimaryButtonText" xml:space="preserve">
<value>Close tab</value>
</data>
<data name="CloseTabWarningDialog.Title" xml:space="preserve">
<value>Warning</value>
</data>
<data name="LargePasteDialog.CloseButtonText" xml:space="preserve">
<value>Cancel</value>
</data>
Expand Down
15 changes: 15 additions & 0 deletions src/cascadia/TerminalApp/TabManagement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,21 @@ namespace winrt::TerminalApp::implementation
}

auto t = winrt::get_self<implementation::Tab>(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));

Expand Down
11 changes: 11 additions & 0 deletions src/cascadia/TerminalApp/TerminalPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<ContentDialogResult> 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
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 @@ -304,6 +304,7 @@ namespace winrt::TerminalApp::implementation
winrt::Windows::Foundation::IAsyncOperation<winrt::Windows::UI::Xaml::Controls::ContentDialogResult> _ShowQuitDialog();
winrt::Windows::Foundation::IAsyncOperation<winrt::Windows::UI::Xaml::Controls::ContentDialogResult> _ShowCloseWarningDialog();
winrt::Windows::Foundation::IAsyncOperation<winrt::Windows::UI::Xaml::Controls::ContentDialogResult> _ShowCloseReadOnlyDialog();
winrt::Windows::Foundation::IAsyncOperation<winrt::Windows::UI::Xaml::Controls::ContentDialogResult> _ShowCloseTabWarningDialog();
winrt::Windows::Foundation::IAsyncOperation<winrt::Windows::UI::Xaml::Controls::ContentDialogResult> _ShowMultiLinePasteWarningDialog();
winrt::Windows::Foundation::IAsyncOperation<winrt::Windows::UI::Xaml::Controls::ContentDialogResult> _ShowLargePasteWarningDialog();

Expand Down
6 changes: 6 additions & 0 deletions src/cascadia/TerminalApp/TerminalPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@
x:Load="False"
DefaultButton="Close" />

<ContentDialog x:Name="CloseTabWarningDialog"
x:Uid="CloseTabWarningDialog"
Grid.Row="2"
x:Load="False"
DefaultButton="Primary" />

<ContentDialog x:Name="MultiLinePasteDialog"
x:Uid="MultiLinePasteDialog"
Grid.Row="2"
Expand Down
1 change: 1 addition & 0 deletions src/cascadia/TerminalSettingsEditor/InteractionViewModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
PERMANENT_OBSERVABLE_PROJECTED_SETTING(_GlobalSettings, SearchWebDefaultQueryUrl);
PERMANENT_OBSERVABLE_PROJECTED_SETTING(_GlobalSettings, WordDelimiters);
PERMANENT_OBSERVABLE_PROJECTED_SETTING(_GlobalSettings, ConfirmCloseAllTabs);
PERMANENT_OBSERVABLE_PROJECTED_SETTING(_GlobalSettings, ConfirmCloseAllPanes);
PERMANENT_OBSERVABLE_PROJECTED_SETTING(_GlobalSettings, InputServiceWarning);
PERMANENT_OBSERVABLE_PROJECTED_SETTING(_GlobalSettings, WarnAboutLargePaste);
PERMANENT_OBSERVABLE_PROJECTED_SETTING(_GlobalSettings, WarnAboutMultiLinePaste);
Expand Down
1 change: 1 addition & 0 deletions src/cascadia/TerminalSettingsModel/GlobalAppSettings.idl
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ namespace Microsoft.Terminal.Settings.Model
INHERITABLE_SETTING(NewTabPosition, NewTabPosition);
INHERITABLE_SETTING(Boolean, ShowTitleInTitlebar);
INHERITABLE_SETTING(Boolean, ConfirmCloseAllTabs);
INHERITABLE_SETTING(Boolean, ConfirmCloseAllPanes);
INHERITABLE_SETTING(String, Language);
INHERITABLE_SETTING(Microsoft.UI.Xaml.Controls.TabViewWidthMode, TabWidthMode);
INHERITABLE_SETTING(Boolean, UseAcrylicInTabRow);
Expand Down
1 change: 1 addition & 0 deletions src/cascadia/TerminalSettingsModel/MTSMSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Author(s):
X(Model::NewTabPosition, NewTabPosition, "newTabPosition", Model::NewTabPosition::AfterLastTab) \
X(bool, ShowTitleInTitlebar, "showTerminalTitleInTitlebar", true) \
X(bool, ConfirmCloseAllTabs, "warning.confirmCloseAllTabs", true) \
X(bool, ConfirmCloseAllPanes, "warning.confirmCloseAllPanes", true) \
X(Model::ThemePair, Theme, "theme") \
X(hstring, Language, "language") \
X(winrt::Microsoft::UI::Xaml::Controls::TabViewWidthMode, TabWidthMode, "tabWidthMode", winrt::Microsoft::UI::Xaml::Controls::TabViewWidthMode::Equal) \
Expand Down
1 change: 1 addition & 0 deletions src/cascadia/TerminalSettingsModel/defaults.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

// Miscellaneous
"confirmCloseAllTabs": true,
"confirmCloseAllPanes": true,
"theme": "dark",
"snapToGridOnResize": true,
"disableAnimations": false,
Expand Down
Loading