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 import os
from powerline.bindings.vim import vim_getbufoption from powerline.bindings.vim import vim_getbufoption, buffer_name
def help(matcher_info): def help(matcher_info):
@ -11,8 +11,8 @@ def help(matcher_info):
def cmdwin(matcher_info): def cmdwin(matcher_info):
name = matcher_info['buffer'].name name = buffer_name(matcher_info)
return name and os.path.basename(name) == '[Command Line]' return name and os.path.basename(name) == b'[Command Line]'
def quickfix(matcher_info): def quickfix(matcher_info):

View File

@ -3,10 +3,13 @@ from __future__ import (unicode_literals, division, absolute_import, print_funct
import os import os
from powerline.bindings.vim import buffer_name
try: try:
import vim import vim
except ImportError: except ImportError:
vim = object() pass
else: else:
vim.command(''' vim.command('''
function! Powerline_plugin_ctrlp_main(...) function! Powerline_plugin_ctrlp_main(...)
@ -26,5 +29,5 @@ else:
def ctrlp(matcher_info): def ctrlp(matcher_info):
name = matcher_info['buffer'].name name = buffer_name(matcher_info)
return name and os.path.basename(name) == 'ControlP' 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 import os
from powerline.bindings.vim import buffer_name
def gundo(matcher_info): def gundo(matcher_info):
name = matcher_info['buffer'].name name = buffer_name(matcher_info)
return name and os.path.basename(name) == '__Gundo__' return name and os.path.basename(name) == b'__Gundo__'
def gundo_preview(matcher_info): def gundo_preview(matcher_info):
name = matcher_info['buffer'].name name = buffer_name(matcher_info)
return name and os.path.basename(name) == '__Gundo_Preview__' 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 os
import re import re
from powerline.bindings.vim import buffer_name
NERD_TREE_RE = re.compile(b'NERD_TREE_\\d+')
def nerdtree(matcher_info): def nerdtree(matcher_info):
name = matcher_info['buffer'].name name = buffer_name(matcher_info)
return name and re.match(r'NERD_tree_\d+', os.path.basename(name)) return name and NERD_TREE_RE.match(os.path.basename(name))