From a325a2fa5a1cee7e46c23934fa6f82bc1922af3c Mon Sep 17 00:00:00 2001 From: Sushaanth Srinivasan <80441330+SushaanthSrinivasan@users.noreply.github.com> Date: Tue, 5 May 2026 19:35:16 -0700 Subject: [PATCH] Fix settings error text legibility in High Contrast mode (#20098) Closes #18147 `SystemErrorTextColor` doesn't adapt to High Contrast themes, so the error details in the "Failed to reload settings" dialog are illegible (yellow on cream in HC White, for example). Fix: skip the `ErrorTextBrush` foreground override when High Contrast is active, letting the text inherit the system HC text color from its parent element. This matches the existing HC detection pattern used in `TermControl.cpp` and `MainPage.cpp`. Validated manually on High Contrast White and Night sky themes. Co-authored-by: SushaanthSrinivasan Co-authored-by: Claude Opus 4.6 (1M context) --- src/cascadia/TerminalApp/TerminalWindow.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/cascadia/TerminalApp/TerminalWindow.cpp b/src/cascadia/TerminalApp/TerminalWindow.cpp index 0fafac603c..67110a1667 100644 --- a/src/cascadia/TerminalApp/TerminalWindow.cpp +++ b/src/cascadia/TerminalApp/TerminalWindow.cpp @@ -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)) + // 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()) { - auto g = resources.Lookup(key); - auto brush = g.try_as(); - textRun.Foreground(brush); + // 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(); + textRun.Foreground(brush); + } } return textRun;