From 01e3fda91b893fb7b465d9c74a874aa877eec61b Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Thu, 13 Aug 2020 14:17:58 -0500 Subject: [PATCH] Don't zoom when there's only one pane (#7273) This is a minor fix from #6989. If there's only one pane in the Terminal, then we'd still "zoom" it and give it a border, but all the borders would be black. A single pane is already "zoomed", so it doesn't really make sense to try and zoom if there's only one. --- src/cascadia/TerminalApp/AppActionHandlers.cpp | 4 +++- src/cascadia/TerminalApp/Tab.cpp | 2 +- src/cascadia/TerminalApp/Tab.h | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/cascadia/TerminalApp/AppActionHandlers.cpp b/src/cascadia/TerminalApp/AppActionHandlers.cpp index 80a06e733de..ad06916cd4e 100644 --- a/src/cascadia/TerminalApp/AppActionHandlers.cpp +++ b/src/cascadia/TerminalApp/AppActionHandlers.cpp @@ -122,7 +122,9 @@ namespace winrt::TerminalApp::implementation const TerminalApp::ActionEventArgs& args) { auto activeTab = _GetFocusedTab(); - if (activeTab) + + // Don't do anything if there's only one pane. It's already zoomed. + if (activeTab && activeTab->GetLeafPaneCount() > 1) { // First thing's first, remove the current content from the UI // tree. This is important, because we might be leaving zoom, and if diff --git a/src/cascadia/TerminalApp/Tab.cpp b/src/cascadia/TerminalApp/Tab.cpp index ead28ce1f02..43f29440745 100644 --- a/src/cascadia/TerminalApp/Tab.cpp +++ b/src/cascadia/TerminalApp/Tab.cpp @@ -960,7 +960,7 @@ namespace winrt::TerminalApp::implementation // - // Return Value: // - The total number of leaf panes hosted by this tab. - int Tab::_GetLeafPaneCount() const noexcept + int Tab::GetLeafPaneCount() const noexcept { return _rootPane->GetLeafPaneCount(); } diff --git a/src/cascadia/TerminalApp/Tab.h b/src/cascadia/TerminalApp/Tab.h index 02055b05767..2cc39b23375 100644 --- a/src/cascadia/TerminalApp/Tab.h +++ b/src/cascadia/TerminalApp/Tab.h @@ -66,6 +66,8 @@ namespace winrt::TerminalApp::implementation void EnterZoom(); void ExitZoom(); + int GetLeafPaneCount() const noexcept; + WINRT_CALLBACK(Closed, winrt::Windows::Foundation::EventHandler); WINRT_CALLBACK(PropertyChanged, Windows::UI::Xaml::Data::PropertyChangedEventHandler); DECLARE_EVENT(ActivePaneChanged, _ActivePaneChangedHandlers, winrt::delegate<>); @@ -102,7 +104,6 @@ namespace winrt::TerminalApp::implementation void _AttachEventHandlersToControl(const winrt::Microsoft::Terminal::TerminalControl::TermControl& control); void _AttachEventHandlersToPane(std::shared_ptr pane); - int _GetLeafPaneCount() const noexcept; void _UpdateActivePane(std::shared_ptr pane); void _UpdateTabHeader();