Skip to content
Open
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
20 changes: 13 additions & 7 deletions src/cascadia/TerminalApp/TerminalWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,19 @@ static Documents::Run _BuildErrorRun(const winrt::hstring& text, const ResourceD
Documents::Run textRun;
textRun.Text(text);

// Color the text red (light theme) or yellow (dark theme) based on the system theme
auto key = winrt::box_value(L"ErrorTextBrush");
if (resources.HasKey(key))
{
auto g = resources.Lookup(key);
auto brush = g.try_as<winrt::Windows::UI::Xaml::Media::Brush>();
textRun.Foreground(brush);
// GH #18147 - In High Contrast mode, don't override the foreground.
// Let the text inherit the system HC text color from its parent element,
// since SystemErrorTextColor doesn't adapt to High Contrast themes.
if (!winrt::Windows::UI::ViewManagement::AccessibilitySettings{}.HighContrast())
{
// Color the text red (light theme) or yellow (dark theme) based on the system theme
auto key = winrt::box_value(L"ErrorTextBrush");
if (resources.HasKey(key))
{
auto g = resources.Lookup(key);
auto brush = g.try_as<winrt::Windows::UI::Xaml::Media::Brush>();
textRun.Foreground(brush);
}
}

return textRun;
Expand Down
Loading