fix(monaco): add high-contrast theme support#1099
Closed
adarsh-priydarshi-5646 wants to merge 1 commit into
Closed
fix(monaco): add high-contrast theme support#1099adarsh-priydarshi-5646 wants to merge 1 commit into
adarsh-priydarshi-5646 wants to merge 1 commit into
Conversation
- Detect high-contrast themes by checking if theme name contains 'high-contrast' - Set Monaco base to 'hc-black' for dark high-contrast themes - Set Monaco base to 'hc-light' for light high-contrast themes - Add comprehensive tests for high-contrast theme detection Fixes #1081
✅ Deploy Preview for shiki-next ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for shiki-matsu ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1099 +/- ##
=======================================
Coverage 88.26% 88.26%
=======================================
Files 74 74
Lines 3298 3298
Branches 948 946 -2
=======================================
Hits 2911 2911
Misses 344 344
Partials 43 43 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Author
|
Hi @antfu, I’ve solved this issue and the PR is ready for review and merge. |
Member
|
Why did you close the PR tho? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes high-contrast theme support in shikiToMonaco by properly detecting and configuring Monaco editor's base theme for high-contrast themes.
Problem:
When using high-contrast themes (like
github-dark-high-contrastorgithub-light-high-contrast) with Monaco editor, the selection foreground color was not being applied correctly. This is because Monaco requires the theme base to be set tohc-blackorhc-lightfor high-contrast mode to work properly, but shikiToMonaco was only usingvsandvs-dark.Solution:
'hc-black'for dark high-contrast themes'hc-light'for light high-contrast themes'vs'(light) and'vs-dark'(dark) as beforeChanges:
hc-blackhc-lightvs-darkvsLinked Issues
Fixes #1081
Additional context
The fix is minimal and backward-compatible. All existing themes continue to work as before, while high-contrast themes now properly enable Monaco's high-contrast mode, making the editor accessible for users who need high-contrast interfaces.
The detection method (checking for "high-contrast" in the theme name) aligns with the existing naming convention used by bundled themes like
github-dark-high-contrastandgithub-light-high-contrast.