From de678ed289a97dc2474e38ad24435f7e5dad6e29 Mon Sep 17 00:00:00 2001 From: ZyX Date: Tue, 9 Apr 2013 00:37:53 +0400 Subject: [PATCH] Create VimPowerline.reset_highlight proxy method Fixes #411 --- powerline/bindings/vim/plugin/powerline.vim | 2 +- powerline/vim.py | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/powerline/bindings/vim/plugin/powerline.vim b/powerline/bindings/vim/plugin/powerline.vim index 1ee4b00d..6ed0f039 100644 --- a/powerline/bindings/vim/plugin/powerline.vim +++ b/powerline/bindings/vim/plugin/powerline.vim @@ -82,7 +82,7 @@ function! PowerlineRegisterCachePurgerEvent(event) endfunction augroup Powerline - autocmd! ColorScheme * :exec s:powerline_pycmd 'powerline.renderer.reset_highlight()' + autocmd! ColorScheme * :exec s:powerline_pycmd 'powerline.reset_highlight()' autocmd! VimEnter * :redrawstatus! autocmd! VimLeavePre * :exec s:powerline_pycmd 'powerline.shutdown()' augroup END diff --git a/powerline/vim.py b/powerline/vim.py index df89b604..b49bd45d 100644 --- a/powerline/vim.py +++ b/powerline/vim.py @@ -82,3 +82,14 @@ class VimPowerline(Powerline): @staticmethod def get_segment_info(): return {} + + def reset_highlight(self): + try: + self.renderer.reset_highlight() + except AttributeError: + # Renderer object appears only after first `.render()` call. Thus if + # ColorScheme event happens before statusline is drawn for the first + # time AttributeError will be thrown for the self.renderer. It is + # fine to ignore it: no renderer == no colors to reset == no need to + # do anything. + pass