Compare bytes() objects in matcher functions

Fixes #1071
This commit is contained in:
ZyX 2014-09-14 13:53:31 +04:00
parent d14aecbc0a
commit 4ed1a7e561
4 changed files with 22 additions and 12 deletions

View File

@ -3,7 +3,7 @@ from __future__ import (unicode_literals, division, absolute_import, print_funct
import os
from powerline.bindings.vim import vim_getbufoption
from powerline.bindings.vim import vim_getbufoption, buffer_name
def help(matcher_info):
@ -11,8 +11,8 @@ def help(matcher_info):
def cmdwin(matcher_info):
name = matcher_info['buffer'].name
return name and os.path.basename(name) == '[Command Line]'
name = buffer_name(matcher_info)
return name and os.path.basename(name) == b'[Command Line]'
def quickfix(matcher_info):

View File

@ -3,10 +3,13 @@ from __future__ import (unicode_literals, division, absolute_import, print_funct
import os
from powerline.bindings.vim import buffer_name
try:
import vim
except ImportError:
vim = object()
pass
else:
vim.command('''
function! Powerline_plugin_ctrlp_main(...)
@ -26,5 +29,5 @@ else:
def ctrlp(matcher_info):
name = matcher_info['buffer'].name
return name and os.path.basename(name) == 'ControlP'
name = buffer_name(matcher_info)
return name and os.path.basename(name) == b'ControlP'

View File

@ -3,12 +3,14 @@ from __future__ import (unicode_literals, division, absolute_import, print_funct
import os
from powerline.bindings.vim import buffer_name
def gundo(matcher_info):
name = matcher_info['buffer'].name
return name and os.path.basename(name) == '__Gundo__'
name = buffer_name(matcher_info)
return name and os.path.basename(name) == b'__Gundo__'
def gundo_preview(matcher_info):
name = matcher_info['buffer'].name
return name and os.path.basename(name) == '__Gundo_Preview__'
name = buffer_name(matcher_info)
return name and os.path.basename(name) == b'__Gundo_Preview__'

View File

@ -4,7 +4,12 @@ from __future__ import (unicode_literals, division, absolute_import, print_funct
import os
import re
from powerline.bindings.vim import buffer_name
NERD_TREE_RE = re.compile(b'NERD_TREE_\\d+')
def nerdtree(matcher_info):
name = matcher_info['buffer'].name
return name and re.match(r'NERD_tree_\d+', os.path.basename(name))
name = buffer_name(matcher_info)
return name and NERD_TREE_RE.match(os.path.basename(name))