mirror of
https://github.com/powerline/powerline.git
synced 2025-07-27 07:44:36 +02:00
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``.
|
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')))
|
skip = not (name and (not vim_getbufoption(segment_info, 'buftype')))
|
||||||
if not skip:
|
if not skip:
|
||||||
repo = guess(path=name, create_watcher=create_watcher)
|
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``.
|
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')))
|
skip = not (name and (not vim_getbufoption(segment_info, 'buftype')))
|
||||||
if not skip:
|
if not skip:
|
||||||
repo = guess(path=name, create_watcher=create_watcher)
|
repo = guess(path=name, create_watcher=create_watcher)
|
||||||
|
@ -146,23 +146,30 @@ class VimPowerline(Powerline):
|
|||||||
self.update_renderer()
|
self.update_renderer()
|
||||||
__main__.powerline = self
|
__main__.powerline = self
|
||||||
|
|
||||||
|
try:
|
||||||
if (
|
if (
|
||||||
bool(int(vim.eval("has('gui_running') && argc() == 0")))
|
bool(int(vim.eval("has('gui_running') && argc() == 0")))
|
||||||
and not vim.current.buffer.name
|
and not vim.current.buffer.name
|
||||||
and len(vim.windows) == 1
|
and len(vim.windows) == 1
|
||||||
):
|
):
|
||||||
# Hack to show startup screen. Problems in GUI:
|
# Hack to show startup screen. Problems in GUI:
|
||||||
# - Defining local value of &statusline option while computing global
|
# - Defining local value of &statusline option while computing
|
||||||
# value purges startup screen.
|
# global value purges startup screen.
|
||||||
# - Defining highlight group while computing statusline purges startup
|
# - Defining highlight group while computing statusline purges
|
||||||
# screen.
|
# startup screen.
|
||||||
# This hack removes the “while computing statusline” part: both things
|
# This hack removes the “while computing statusline” part: both
|
||||||
# are defined, but they are defined right now.
|
# things are defined, but they are defined right now.
|
||||||
#
|
#
|
||||||
# The above condition disables this hack if no GUI is running, Vim did
|
# The above condition disables this hack if no GUI is running,
|
||||||
# not open any files and there is only one window. Without GUI
|
# Vim did not open any files and there is only one window.
|
||||||
# everything works, in other cases startup screen is not shown.
|
# Without GUI everything works, in other cases startup screen is
|
||||||
|
# not shown.
|
||||||
self.new_window()
|
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
|
# 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
|
# context newline is considered part of the command in just the same cases
|
||||||
|
Loading…
x
Reference in New Issue
Block a user