From a5ff7459b76f28f512e911711e565f40f573a236 Mon Sep 17 00:00:00 2001 From: Don-Vito Date: Mon, 22 Mar 2021 22:48:18 +0200 Subject: [PATCH] Prevent tab context menu from closing root pane directly (#9571) ## Summary of the Pull Request Currently a repeated attempt to close a read-only tab from context menu, will bring the terminal into invalid state if user dismisses close action. There are two root causes for this: 1. The tab close menu triggers the closing of the root pane (rather than invoking close tab flow in the Terminal Page). 2. Currently panes are not aware that the closing was canceled, and thus they trigger the Closed event, putting the system in a weird state, where the Closed handlers were invoked, but the Pane remains. This PR mitigates #9502, by addressing the first root cause (the fix is trivial and hopefully can be serviced). Moreover, it addresses the only existing UI flow that can trigger the issue. The remaining problematic flow will occur when the connection is closed. I have created a separate Issue to track it: https://github.com/microsoft/terminal/issues/9572 as I guess the PR for it might be more complex. ## PR Checklist * [x] Closes https://github.com/microsoft/terminal/issues/9502 * [x] CLA signed. * [ ] Tests added/passed * [ ] Documentation updated. * [ ] Schema updated. * [ ] I've discussed this with core contributors already. --- src/cascadia/TerminalApp/TerminalTab.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cascadia/TerminalApp/TerminalTab.cpp b/src/cascadia/TerminalApp/TerminalTab.cpp index 5a6015220..9c41307b7 100644 --- a/src/cascadia/TerminalApp/TerminalTab.cpp +++ b/src/cascadia/TerminalApp/TerminalTab.cpp @@ -788,7 +788,7 @@ namespace winrt::TerminalApp::implementation closeTabMenuItem.Click([weakThis](auto&&, auto&&) { if (auto tab{ weakThis.get() }) { - tab->_rootPane->Close(); + tab->_ClosedHandlers(nullptr, nullptr); } }); closeTabMenuItem.Text(RS_(L"TabClose"));