Do not use segment_info['buffer'].name ever
This results in UnicodeDecodeErrors for non-unicode filenames
This commit is contained in:
parent
a4e711dae7
commit
f8b9ad4ac4
|
@ -489,7 +489,7 @@ def branch(pl, segment_info, create_watcher, status_colors=False):
|
|||
|
||||
Divider highlight group used: ``branch:divider``.
|
||||
'''
|
||||
name = segment_info['buffer'].name
|
||||
name = buffer_name(segment_info)
|
||||
skip = not (name and (not vim_getbufoption(segment_info, 'buftype')))
|
||||
if not skip:
|
||||
repo = guess(path=name, create_watcher=create_watcher)
|
||||
|
@ -513,7 +513,7 @@ def file_vcs_status(pl, segment_info, create_watcher):
|
|||
|
||||
Highlight groups used: ``file_vcs_status``.
|
||||
'''
|
||||
name = segment_info['buffer'].name
|
||||
name = buffer_name(segment_info)
|
||||
skip = not (name and (not vim_getbufoption(segment_info, 'buftype')))
|
||||
if not skip:
|
||||
repo = guess(path=name, create_watcher=create_watcher)
|
||||
|
|
|
@ -146,23 +146,30 @@ class VimPowerline(Powerline):
|
|||
self.update_renderer()
|
||||
__main__.powerline = self
|
||||
|
||||
if (
|
||||
bool(int(vim.eval("has('gui_running') && argc() == 0")))
|
||||
and not vim.current.buffer.name
|
||||
and len(vim.windows) == 1
|
||||
):
|
||||
# Hack to show startup screen. Problems in GUI:
|
||||
# - Defining local value of &statusline option while computing global
|
||||
# value purges startup screen.
|
||||
# - Defining highlight group while computing statusline purges startup
|
||||
# screen.
|
||||
# This hack removes the “while computing statusline” part: both things
|
||||
# are defined, but they are defined right now.
|
||||
#
|
||||
# The above condition disables this hack if no GUI is running, Vim did
|
||||
# not open any files and there is only one window. Without GUI
|
||||
# everything works, in other cases startup screen is not shown.
|
||||
self.new_window()
|
||||
try:
|
||||
if (
|
||||
bool(int(vim.eval("has('gui_running') && argc() == 0")))
|
||||
and not vim.current.buffer.name
|
||||
and len(vim.windows) == 1
|
||||
):
|
||||
# Hack to show startup screen. Problems in GUI:
|
||||
# - Defining local value of &statusline option while computing
|
||||
# global value purges startup screen.
|
||||
# - Defining highlight group while computing statusline purges
|
||||
# startup screen.
|
||||
# This hack removes the “while computing statusline” part: both
|
||||
# things are defined, but they are defined right now.
|
||||
#
|
||||
# The above condition disables this hack if no GUI is running,
|
||||
# Vim did not open any files and there is only one window.
|
||||
# Without GUI everything works, in other cases startup screen is
|
||||
# not shown.
|
||||
self.new_window()
|
||||
except UnicodeDecodeError:
|
||||
# vim.current.buffer.name may raise UnicodeDecodeError when using
|
||||
# Python-3*. Fortunately, this means that current buffer is not
|
||||
# empty buffer, so the above condition should be False.
|
||||
pass
|
||||
|
||||
# Cannot have this in one line due to weird newline handling (in :execute
|
||||
# context newline is considered part of the command in just the same cases
|
||||
|
|
Loading…
Reference in New Issue