Skip to content

Fix Monaco Editor text selection visibility in High Contrast Mode#45426

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/fix-text-selection-high-contrast
Draft

Fix Monaco Editor text selection visibility in High Contrast Mode#45426
Copilot wants to merge 2 commits intomainfrom
copilot/fix-text-selection-high-contrast

Conversation

Copy link
Contributor

Copilot AI commented Feb 5, 2026

Summary of the Pull Request

Monaco Editor text selection was invisible in High Contrast Mode across Peek, Registry Preview, and File Explorer Preview Pane. Monaco provides built-in HC themes (hc-black, hc-light) but PowerToys only passed standard themes (vs, vs-dark). Fixed by detecting HC mode and using appropriate theme names.

PR Checklist

  • Communication: I've discussed this with core contributors already. If the work hasn't been agreed, this work might be rejected
  • Tests: Added/updated and all pass
  • Localization: All end-user-facing strings can be localized
  • Dev docs: Added/updated
  • New binaries: Added on the required places
  • Documentation updated: If checked, please file a pull request on our docs repo and link it here: #xxx

Detailed Description of the Pull Request / Additional comments

Core Change: Added ThemeManager.GetMonacoTheme() returning Monaco theme names based on HC state:

public static string GetMonacoTheme()
{
    if (ControlzEx.Theming.WindowsThemeHelper.IsHighContrastEnabled())
    {
        string baseColor = ControlzEx.Theming.WindowsThemeHelper.GetWindowsBaseColor();
        return baseColor.Equals("Dark", StringComparison.OrdinalIgnoreCase) ? "hc-black" : "hc-light";
    }
    return baseColor.Equals("Dark", StringComparison.OrdinalIgnoreCase) ? "vs-dark" : "vs";
}

Implementation across components:

  • Monaco Preview Handler & Peek: Call GetMonacoTheme() instead of GetWindowsBaseColor()
  • Registry Preview: Uses WinUI3 UISettings.HighContrast with luminance calculation to determine dark vs light HC theme
  • Monaco HTML: Pass full theme name; only apply custom token rules to non-HC themes to preserve Monaco's WCAG-compliant HC styling

Theme mapping:

Mode Theme
Normal Light/Dark vs / vs-dark
HC Light/Dark hc-light / hc-black

Validation Steps Performed

  1. Enable High Contrast theme (Settings → Accessibility → Contrast themes)
  2. Open code file in File Explorer Preview Pane, Peek (Win+Shift+Space), and Registry Preview
  3. Select text in Monaco Editor
  4. Verify selection visible with proper contrast colors
Original prompt

This section details on the original issue you should resolve

<issue_title>[Peek, Registry Preview, File Explorer Addons] Monaco Editor: Text selection not visible in High Contrast Mode</issue_title>
<issue_description>### Microsoft PowerToys version

0.88.0

Installation method

PowerToys auto-update

Running as admin

None

Area(s) with issue?

File Explorer: Preview Pane, Peek, Registry Preview

Steps to reproduce

  1. Enable High Contrast theme.
  2. Open for example Peek with a text file.
  3. Select text.

✔️ Expected Behavior

Selection is visible and uses the correct color.

❌ Actual Behavior

With High Contrast theme enabled the background color and text color for selected text in Monaco Editor control does not change. The selection is transparent/not visible.

Other Software

No response</issue_description>

<agent_instructions>Implement a proper fix for this issue. Do NOT create placeholder stub files. Create actual working code that addresses the issue described. Follow PowerToys coding guidelines and conventions.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

- Add GetMonacoTheme() to ThemeManager for detecting high contrast mode
- Update Monaco index.html to support hc-black and hc-light themes
- Update Monaco Preview Handler to use high contrast themes
- Update Peek to use high contrast themes
- Update Registry Preview to detect and use high contrast themes

Co-authored-by: yeelam-gordon <73506701+yeelam-gordon@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix text selection visibility in High Contrast Mode Fix Monaco Editor text selection visibility in High Contrast Mode Feb 5, 2026
Copilot AI requested a review from yeelam-gordon February 5, 2026 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Peek, Registry Preview, File Explorer Addons] Monaco Editor: Text selection not visible in High Contrast Mode

2 participants