diff --git a/src/cascadia/TerminalControl/XamlUiaTextRange.cpp b/src/cascadia/TerminalControl/XamlUiaTextRange.cpp index 80a9b623d40..966e0c79068 100644 --- a/src/cascadia/TerminalControl/XamlUiaTextRange.cpp +++ b/src/cascadia/TerminalControl/XamlUiaTextRange.cpp @@ -24,6 +24,18 @@ namespace XamlAutomation namespace winrt::Microsoft::Terminal::TerminalControl::implementation { + // EmptyObject is our equivalent of UIAutomationCore::UiaGetReservedNotSupportedValue() + // This retrieves a value that is interpreted as "not supported". + class EmptyObject : public winrt::implements + { + public: + static IInspectable GetInstance() + { + static auto eo = make_self(); + return eo.as(); + } + }; + XamlAutomation::ITextRangeProvider XamlUiaTextRange::Clone() const { UIA::ITextRangeProvider* pReturn; @@ -88,7 +100,9 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation } else { - return nullptr; + // We _need_ to return an empty object here. + // Returning nullptr is an improper implementation of it being unsupported. + return EmptyObject::GetInstance();//*EmptyObject::GetInstance(); } }