Fix highlighting when there are only 2 segments in theme
Here are two fixes: - defaultdict makes it not throw KeyErrors. - Replacing (False, False) with False makes it not throw vim.error (no color ctermbg=False)
This commit is contained in:
parent
b4fc8ebe91
commit
033afade95
|
@ -26,12 +26,12 @@ class TerminalRenderer(Renderer):
|
|||
'''
|
||||
ansi = []
|
||||
if fg is not None:
|
||||
if fg[0] is False:
|
||||
if fg is False or fg[0] is False:
|
||||
ansi += [39]
|
||||
else:
|
||||
ansi += [38, 5, fg[0]]
|
||||
if bg is not None:
|
||||
if bg[0] is False:
|
||||
if bg is False or bg[0] is False:
|
||||
ansi += [49]
|
||||
else:
|
||||
ansi += [48, 5, bg[0]]
|
||||
|
|
|
@ -12,12 +12,12 @@ class TmuxRenderer(Renderer):
|
|||
return ''
|
||||
tmux_attr = []
|
||||
if fg is not None:
|
||||
if fg[0] is False:
|
||||
if fg is False or fg[0] is False:
|
||||
tmux_attr += ['fg=default']
|
||||
else:
|
||||
tmux_attr += ['fg=colour' + str(fg[0])]
|
||||
if bg is not None:
|
||||
if bg[0] is False:
|
||||
if bg is False or bg[0] is False:
|
||||
tmux_attr += ['bg=default']
|
||||
else:
|
||||
tmux_attr += ['bg=colour' + str(bg[0])]
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
import copy
|
||||
|
||||
from collections import defaultdict
|
||||
|
||||
class Theme(object):
|
||||
def __init__(self, ext, colorscheme, theme_config, common_config, get_segment):
|
||||
|
@ -10,7 +11,7 @@ class Theme(object):
|
|||
self.segments = []
|
||||
self.EMPTY_SEGMENT = {
|
||||
'contents': None,
|
||||
'highlight': {self.colorscheme.DEFAULT_MODE_KEY: {'fg': (False, False), 'bg': (False, False), 'attr': 0}}
|
||||
'highlight': defaultdict(lambda : {'fg': False, 'bg': False, 'attr': 0})
|
||||
}
|
||||
for side in ['left', 'right']:
|
||||
self.segments.extend((get_segment(segment, side) for segment in theme_config['segments'].get(side, [])))
|
||||
|
|
Loading…
Reference in New Issue