mirror of
https://github.com/powerline/powerline.git
synced 2025-07-28 08:14:41 +02:00
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 = []
|
ansi = []
|
||||||
if fg is not None:
|
if fg is not None:
|
||||||
if fg[0] is False:
|
if fg is False or fg[0] is False:
|
||||||
ansi += [39]
|
ansi += [39]
|
||||||
else:
|
else:
|
||||||
ansi += [38, 5, fg[0]]
|
ansi += [38, 5, fg[0]]
|
||||||
if bg is not None:
|
if bg is not None:
|
||||||
if bg[0] is False:
|
if bg is False or bg[0] is False:
|
||||||
ansi += [49]
|
ansi += [49]
|
||||||
else:
|
else:
|
||||||
ansi += [48, 5, bg[0]]
|
ansi += [48, 5, bg[0]]
|
||||||
|
@ -12,12 +12,12 @@ class TmuxRenderer(Renderer):
|
|||||||
return ''
|
return ''
|
||||||
tmux_attr = []
|
tmux_attr = []
|
||||||
if fg is not None:
|
if fg is not None:
|
||||||
if fg[0] is False:
|
if fg is False or fg[0] is False:
|
||||||
tmux_attr += ['fg=default']
|
tmux_attr += ['fg=default']
|
||||||
else:
|
else:
|
||||||
tmux_attr += ['fg=colour' + str(fg[0])]
|
tmux_attr += ['fg=colour' + str(fg[0])]
|
||||||
if bg is not None:
|
if bg is not None:
|
||||||
if bg[0] is False:
|
if bg is False or bg[0] is False:
|
||||||
tmux_attr += ['bg=default']
|
tmux_attr += ['bg=default']
|
||||||
else:
|
else:
|
||||||
tmux_attr += ['bg=colour' + str(bg[0])]
|
tmux_attr += ['bg=colour' + str(bg[0])]
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import copy
|
import copy
|
||||||
|
|
||||||
|
from collections import defaultdict
|
||||||
|
|
||||||
class Theme(object):
|
class Theme(object):
|
||||||
def __init__(self, ext, colorscheme, theme_config, common_config, get_segment):
|
def __init__(self, ext, colorscheme, theme_config, common_config, get_segment):
|
||||||
@ -10,7 +11,7 @@ class Theme(object):
|
|||||||
self.segments = []
|
self.segments = []
|
||||||
self.EMPTY_SEGMENT = {
|
self.EMPTY_SEGMENT = {
|
||||||
'contents': None,
|
'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']:
|
for side in ['left', 'right']:
|
||||||
self.segments.extend((get_segment(segment, side) for segment in theme_config['segments'].get(side, [])))
|
self.segments.extend((get_segment(segment, side) for segment in theme_config['segments'].get(side, [])))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user