diff --git a/src/cascadia/TerminalApp/Pane.cpp b/src/cascadia/TerminalApp/Pane.cpp index 659d7bf4002..42251bc9ca5 100644 --- a/src/cascadia/TerminalApp/Pane.cpp +++ b/src/cascadia/TerminalApp/Pane.cpp @@ -1304,6 +1304,11 @@ TermControl Pane::GetTerminalControl() const return _IsLeaf() ? _control.try_as() : nullptr; } +Controls::UserControl Pane::GetUserControl() const +{ + return _IsLeaf() ? _control : nullptr; +} + // Method Description: // - Recursively remove the "Active" state from this Pane and all it's children. // - Updates our visuals to match our new state, including highlighting our borders. diff --git a/src/cascadia/TerminalApp/Pane.h b/src/cascadia/TerminalApp/Pane.h index 5dba77c501c..dd9e08f0be8 100644 --- a/src/cascadia/TerminalApp/Pane.h +++ b/src/cascadia/TerminalApp/Pane.h @@ -66,9 +66,10 @@ class Pane : public std::enable_shared_from_this const bool lastFocused = false); std::shared_ptr GetActivePane(); - winrt::Microsoft::Terminal::Control::TermControl GetLastFocusedTerminalControl(); + winrt::Windows::UI::Xaml::Controls::UserControl GetUserControl() const; winrt::Microsoft::Terminal::Control::TermControl GetTerminalControl() const; winrt::Microsoft::Terminal::Settings::Model::Profile GetFocusedProfile(); + winrt::Microsoft::Terminal::Control::TermControl GetLastFocusedTerminalControl(); // Method Description: // - If this is a leaf pane, return its profile. diff --git a/src/cascadia/TerminalApp/TerminalTab.cpp b/src/cascadia/TerminalApp/TerminalTab.cpp index eb223e0abb9..2be3c2c0783 100644 --- a/src/cascadia/TerminalApp/TerminalTab.cpp +++ b/src/cascadia/TerminalApp/TerminalTab.cpp @@ -437,7 +437,10 @@ namespace winrt::TerminalApp::implementation winrt::fire_and_forget TerminalTab::Scroll(const int delta) { auto control = GetActiveTerminalControl(); - + if (!control) + { + co_return; + } co_await winrt::resume_foreground(control.Dispatcher()); const auto currentOffset = control.ScrollOffset(); @@ -1341,6 +1344,13 @@ namespace winrt::TerminalApp::implementation // - The tab's color, if any std::optional TerminalTab::GetTabColor() { + const auto& termControl{ GetActiveTerminalControl() }; + if (!termControl) + { + return std::nullopt; + } + + const auto currControlColor{ termControl.TabColor() }; std::optional controlTabColor; if (const auto& control = GetActiveTerminalControl()) {