I’ve encountered a minor theming question that’s more of an annoyance than an issue, but I wanted to ask for clarifications. Specifically, a CodeMirror instance can be styled according to the color scheme (dark or light) via special selectors &dark
/&light
. But these selectors do not make them precedent over the built-in rules without one. This makes the precendence of rules not consistent.
This property was mentioned by this older thread using a legacy syntax, but my intention is to style the base elements further.
I can try to explain it with the following scenerio: The base theme has a rule named &dark .cm-cursor
targeting the cursor in dark themes. If I include the same rule to specify a different color in my base theme, the original color will be overridden. However, things behave differently when the base theme rule is not scoped with &dark
. Take a look at .cm-selectionMatch
targeting highlight decorations matching the current selection. That rule has no dark counterparts. I want to specify it as &dark .cm-selectionMatch
, but confusingly it will not override the original rule.
A solution is to only ever use regular themes to override what the base theme has provided. But I think the use could be avoided with a more consistent, cascading way, like treating &dark
as two classes in conjunction (conceptually .cm-editor.dark
).