Fix color application in dark mode

This commit is contained in:
Kovid Goyal 2020-08-04 23:07:42 +05:30
parent 2c8f751455
commit 57bbbf97a8
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -125,30 +125,28 @@ class HighlightStyle:
def highlight_style_as_css(s, is_dark, foreground): def highlight_style_as_css(s, is_dark, foreground):
def styler(node): def styler(node):
node = node.style def set(name, val):
if val:
node.style.setProperty(name, val, 'important')
if s.kind is 'decoration': if s.kind is 'decoration':
if s.type is 'builtin': if s.type is 'builtin':
keys = builtin_decorations_dark[s.which] if is_dark else builtin_decorations_light[s.which] keys = builtin_decorations_dark[s.which] if is_dark else builtin_decorations_light[s.which]
else: else:
keys = s keys = s
if keys['text-decoration-line']: set('text-decoration-line', keys['text-decoration-line'])
node.textDecorationLine = keys['text-decoration-line'] set('text-decoration-color', keys['text-decoration-color'])
if keys['text-decoration-color']: set('text-decoration-style', keys['text-decoration-style'])
node.textDecorationColor = keys['text-decoration-color']
if keys['text-decoration-style']:
node.textDecorationStyle = keys['text-decoration-style']
return return
bg = fg = None
if s.type is 'builtin': if s.type is 'builtin':
if s.kind is 'color': if s.kind is 'color':
node.backgroundColor = builtin_color(s.which, is_dark) bg = builtin_color(s.which, is_dark)
if foreground: if foreground:
node.color = foreground fg = foreground
return set('background-color', bg or s['background-color'] or default_color(is_dark))
node.backgroundColor = s['background-color'] or default_color(is_dark) set('color', fg or s.color or foreground)
fg = s.color or foreground
if fg:
node.color = fg
return styler return styler