mirror of
https://github.com/powerline/powerline.git
synced 2025-07-29 00:34:49 +02:00
commit
6430877ec9
@ -325,13 +325,14 @@ Themes
|
|||||||
A dict where keys are segment names or strings ``{module}.{name}``. Used to
|
A dict where keys are segment names or strings ``{module}.{name}``. Used to
|
||||||
specify default values for various keys:
|
specify default values for various keys:
|
||||||
:ref:`after <config-theme-seg-after>`,
|
:ref:`after <config-theme-seg-after>`,
|
||||||
|
:ref:`args <config-themes-seg-args>` (only for function segments),
|
||||||
:ref:`before <config-theme-seg-before>`,
|
:ref:`before <config-theme-seg-before>`,
|
||||||
:ref:`contents <config-theme-seg-contents>` (only for string segments
|
:ref:`contents <config-theme-seg-contents>` (only for string segments
|
||||||
if :ref:`name <config-themes-seg-name>` is defined),
|
if :ref:`name <config-themes-seg-name>` is defined),
|
||||||
:ref:`args <config-themes-seg-args>` (only for function segments). When
|
:ref:`display <config-theme-seg-display`.
|
||||||
using :ref:`local themes <config-ext-local_themes>` values of these keys are
|
When using :ref:`local themes <config-ext-local_themes>` values of these
|
||||||
first searched in the segment description, then in ``segment_data`` key of
|
keys are first searched in the segment description, then in ``segment_data``
|
||||||
a local theme, then in ``segment_data`` key of a :ref:`default theme
|
key of a local theme, then in ``segment_data`` key of a :ref:`default theme
|
||||||
<config-ext-theme>`. For the :ref:`default theme <config-ext-theme>` itself
|
<config-ext-theme>`. For the :ref:`default theme <config-ext-theme>` itself
|
||||||
step 2 is obviously avoided.
|
step 2 is obviously avoided.
|
||||||
|
|
||||||
@ -455,6 +456,12 @@ Themes
|
|||||||
A list of modes where this segment will be included: The segment is
|
A list of modes where this segment will be included: The segment is
|
||||||
*not* included in any modes, *except* for the modes in this list.
|
*not* included in any modes, *except* for the modes in this list.
|
||||||
|
|
||||||
|
``display``
|
||||||
|
.. _config-themes-seg-display:
|
||||||
|
|
||||||
|
Boolean. If false disables displaying of the segment.
|
||||||
|
Defaults to ``True``.
|
||||||
|
|
||||||
Segments
|
Segments
|
||||||
========
|
========
|
||||||
|
|
||||||
|
@ -159,4 +159,31 @@ def powerline_vim_strtrans_error(e):
|
|||||||
codecs.register_error('powerline_vim_strtrans_error', powerline_vim_strtrans_error)
|
codecs.register_error('powerline_vim_strtrans_error', powerline_vim_strtrans_error)
|
||||||
|
|
||||||
|
|
||||||
|
did_autocmd = False
|
||||||
|
buffer_caches = []
|
||||||
|
|
||||||
|
|
||||||
|
def register_buffer_cache(cachedict):
|
||||||
|
global did_autocmd
|
||||||
|
global buffer_caches
|
||||||
|
from powerline.vim import get_default_pycmd, pycmd
|
||||||
|
if not did_autocmd:
|
||||||
|
import __main__
|
||||||
|
__main__.powerline_on_bwipe = on_bwipe
|
||||||
|
vim.command('augroup Powerline')
|
||||||
|
vim.command(' autocmd! BufWipeout * :{pycmd} powerline_on_bwipe()'.format(
|
||||||
|
pycmd=(pycmd or get_default_pycmd())))
|
||||||
|
vim.command('augroup END')
|
||||||
|
did_autocmd = True
|
||||||
|
buffer_caches.append(cachedict)
|
||||||
|
return cachedict
|
||||||
|
|
||||||
|
|
||||||
|
def on_bwipe():
|
||||||
|
global buffer_caches
|
||||||
|
bufnr = int(vim.eval('expand("<abuf>")'))
|
||||||
|
for cachedict in buffer_caches:
|
||||||
|
cachedict.pop(bufnr, None)
|
||||||
|
|
||||||
|
|
||||||
environ = VimEnviron()
|
environ = VimEnviron()
|
||||||
|
@ -58,6 +58,12 @@
|
|||||||
"name": "modified_indicator",
|
"name": "modified_indicator",
|
||||||
"before": " "
|
"before": " "
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"exclude_modes": ["i", "R", "Rv"],
|
||||||
|
"name": "trailing_whitespace",
|
||||||
|
"display": false,
|
||||||
|
"priority": 60
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"exclude_modes": ["nc"],
|
"exclude_modes": ["nc"],
|
||||||
"module": "powerline.segments.plugin.syntastic",
|
"module": "powerline.segments.plugin.syntastic",
|
||||||
|
@ -668,17 +668,25 @@ shell_colorscheme_spec = (Spec(
|
|||||||
).context_message('Error while loading shell colorscheme'))
|
).context_message('Error while loading shell colorscheme'))
|
||||||
|
|
||||||
|
|
||||||
generic_keys = set(('exclude_modes', 'include_modes', 'width', 'align', 'name', 'draw_soft_divider', 'draw_hard_divider', 'priority', 'after', 'before'))
|
generic_keys = set((
|
||||||
|
'exclude_modes', 'include_modes',
|
||||||
|
'width', 'align',
|
||||||
|
'name',
|
||||||
|
'draw_soft_divider', 'draw_hard_divider',
|
||||||
|
'priority',
|
||||||
|
'after', 'before',
|
||||||
|
'display'
|
||||||
|
))
|
||||||
type_keys = {
|
type_keys = {
|
||||||
'function': set(('args', 'module', 'draw_inner_divider')),
|
'function': set(('args', 'module', 'draw_inner_divider')),
|
||||||
'string': set(('contents', 'type', 'highlight_group', 'divider_highlight_group')),
|
'string': set(('contents', 'type', 'highlight_group', 'divider_highlight_group')),
|
||||||
'filler': set(('type', 'highlight_group', 'divider_highlight_group')),
|
'filler': set(('type', 'highlight_group', 'divider_highlight_group')),
|
||||||
}
|
}
|
||||||
required_keys = {
|
required_keys = {
|
||||||
'function': set(),
|
'function': set(),
|
||||||
'string': set(('contents',)),
|
'string': set(('contents',)),
|
||||||
'filler': set(),
|
'filler': set(),
|
||||||
}
|
}
|
||||||
function_keys = set(('args', 'module'))
|
function_keys = set(('args', 'module'))
|
||||||
highlight_keys = set(('highlight_group', 'name'))
|
highlight_keys = set(('highlight_group', 'name'))
|
||||||
|
|
||||||
@ -1071,6 +1079,7 @@ segments_spec = Spec().optional().list(
|
|||||||
draw_hard_divider=Spec().type(bool).optional(),
|
draw_hard_divider=Spec().type(bool).optional(),
|
||||||
draw_soft_divider=Spec().type(bool).optional(),
|
draw_soft_divider=Spec().type(bool).optional(),
|
||||||
draw_inner_divider=Spec().type(bool).optional(),
|
draw_inner_divider=Spec().type(bool).optional(),
|
||||||
|
display=Spec().type(bool).optional(),
|
||||||
module=segment_module_spec(),
|
module=segment_module_spec(),
|
||||||
priority=Spec().type(int, float, type(None)).optional(),
|
priority=Spec().type(int, float, type(None)).optional(),
|
||||||
after=Spec().type(unicode).optional(),
|
after=Spec().type(unicode).optional(),
|
||||||
@ -1101,6 +1110,7 @@ theme_spec = (Spec(
|
|||||||
Spec(
|
Spec(
|
||||||
after=Spec().type(unicode).optional(),
|
after=Spec().type(unicode).optional(),
|
||||||
before=Spec().type(unicode).optional(),
|
before=Spec().type(unicode).optional(),
|
||||||
|
display=Spec().type(bool).optional(),
|
||||||
args=args_spec().func(lambda *args, **kwargs: check_args(get_all_possible_segments, *args, **kwargs)),
|
args=args_spec().func(lambda *args, **kwargs: check_args(get_all_possible_segments, *args, **kwargs)),
|
||||||
contents=Spec().type(unicode).optional(),
|
contents=Spec().type(unicode).optional(),
|
||||||
),
|
),
|
||||||
|
@ -82,6 +82,9 @@ def gen_segment_getter(pl, ext, common_config, theme_configs, default_module=Non
|
|||||||
pl.exception('Failed to generate segment from {0!r}: {1}', segment, str(e), prefix='segment_generator')
|
pl.exception('Failed to generate segment from {0!r}: {1}', segment, str(e), prefix='segment_generator')
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
if not get_key(segment, module, 'display', True):
|
||||||
|
return None
|
||||||
|
|
||||||
if segment_type == 'function':
|
if segment_type == 'function':
|
||||||
highlight_group = [module + '.' + segment['name'], segment['name']]
|
highlight_group = [module + '.' + segment['name'], segment['name']]
|
||||||
else:
|
else:
|
||||||
|
@ -8,8 +8,14 @@ try:
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
vim = {} # NOQA
|
vim = {} # NOQA
|
||||||
|
|
||||||
|
try:
|
||||||
|
from __builtin__ import xrange as range
|
||||||
|
except ImportError:
|
||||||
|
pass
|
||||||
|
|
||||||
from powerline.bindings.vim import (vim_get_func, getbufvar, vim_getbufoption,
|
from powerline.bindings.vim import (vim_get_func, getbufvar, vim_getbufoption,
|
||||||
buffer_name, vim_getwinvar)
|
buffer_name, vim_getwinvar,
|
||||||
|
register_buffer_cache)
|
||||||
from powerline.theme import requires_segment_info, requires_filesystem_watcher
|
from powerline.theme import requires_segment_info, requires_filesystem_watcher
|
||||||
from powerline.lib import add_divider_highlight_group
|
from powerline.lib import add_divider_highlight_group
|
||||||
from powerline.lib.vcs import guess, tree_status
|
from powerline.lib.vcs import guess, tree_status
|
||||||
@ -17,6 +23,7 @@ from powerline.lib.humanize_bytes import humanize_bytes
|
|||||||
from powerline.lib import wraps_saveargs as wraps
|
from powerline.lib import wraps_saveargs as wraps
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
|
||||||
|
|
||||||
vim_funcs = {
|
vim_funcs = {
|
||||||
'virtcol': vim_get_func('virtcol', rettype=int),
|
'virtcol': vim_get_func('virtcol', rettype=int),
|
||||||
'getpos': vim_get_func('getpos'),
|
'getpos': vim_get_func('getpos'),
|
||||||
@ -420,3 +427,55 @@ def file_vcs_status(pl, segment_info, create_watcher):
|
|||||||
'highlight_group': ['file_vcs_status_' + status, 'file_vcs_status'],
|
'highlight_group': ['file_vcs_status_' + status, 'file_vcs_status'],
|
||||||
})
|
})
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
|
trailing_whitespace_cache = None
|
||||||
|
|
||||||
|
|
||||||
|
@requires_segment_info
|
||||||
|
def trailing_whitespace(pl, segment_info):
|
||||||
|
'''Return the line number for trailing whitespaces
|
||||||
|
|
||||||
|
It is advised not to use this segment in insert mode: in Insert mode it will
|
||||||
|
iterate over all lines in buffer each time you happen to type a character
|
||||||
|
which may cause lags. It will also show you whitespace warning each time you
|
||||||
|
happen to type space.
|
||||||
|
|
||||||
|
Highlight groups used: ``trailing_whitespace`` or ``warning``.
|
||||||
|
'''
|
||||||
|
global trailing_whitespace_cache
|
||||||
|
if trailing_whitespace_cache is None:
|
||||||
|
trailing_whitespace_cache = register_buffer_cache(defaultdict(lambda: (0, None)))
|
||||||
|
bufnr = segment_info['bufnr']
|
||||||
|
changedtick = getbufvar(bufnr, 'changedtick')
|
||||||
|
if trailing_whitespace_cache[bufnr][0] == changedtick:
|
||||||
|
return trailing_whitespace_cache[bufnr][1]
|
||||||
|
else:
|
||||||
|
buf = segment_info['buffer']
|
||||||
|
bws = b' \t'
|
||||||
|
sws = str(bws)
|
||||||
|
for i in range(len(buf)):
|
||||||
|
try:
|
||||||
|
line = buf[i]
|
||||||
|
except UnicodeDecodeError: # May happen in Python 3
|
||||||
|
if hasattr(vim, 'bindeval'):
|
||||||
|
line = vim.bindeval('getbufline({0}, {1})'.format(
|
||||||
|
bufnr, i + 1))
|
||||||
|
has_trailing_ws = (line[-1] in bws)
|
||||||
|
else:
|
||||||
|
line = vim.eval('strtrans(getbufline({0}, {1}))'.format(
|
||||||
|
bufnr, i + 1))
|
||||||
|
has_trailing_ws = (line[-1] in bws)
|
||||||
|
else:
|
||||||
|
has_trailing_ws = (line and line[-1] in sws)
|
||||||
|
if has_trailing_ws:
|
||||||
|
break
|
||||||
|
if has_trailing_ws:
|
||||||
|
ret = [{
|
||||||
|
'contents': str(i + 1),
|
||||||
|
'highlight_group': ['trailing_whitespace', 'warning'],
|
||||||
|
}]
|
||||||
|
else:
|
||||||
|
ret = None
|
||||||
|
trailing_whitespace_cache[bufnr] = (changedtick, ret)
|
||||||
|
return ret
|
||||||
|
@ -49,14 +49,15 @@ class Theme(object):
|
|||||||
for side in ['left', 'right']:
|
for side in ['left', 'right']:
|
||||||
for segment in segdict.get(side, []):
|
for segment in segdict.get(side, []):
|
||||||
segment = get_segment(segment, side)
|
segment = get_segment(segment, side)
|
||||||
if not run_once:
|
if segment:
|
||||||
if segment['startup']:
|
if not run_once:
|
||||||
try:
|
if segment['startup']:
|
||||||
segment['startup'](pl, shutdown_event)
|
try:
|
||||||
except Exception as e:
|
segment['startup'](pl, shutdown_event)
|
||||||
pl.error('Exception during {0} startup: {1}', segment['name'], str(e))
|
except Exception as e:
|
||||||
continue
|
pl.error('Exception during {0} startup: {1}', segment['name'], str(e))
|
||||||
self.segments[-1][side].append(segment)
|
continue
|
||||||
|
self.segments[-1][side].append(segment)
|
||||||
|
|
||||||
def shutdown(self):
|
def shutdown(self):
|
||||||
for line in self.segments:
|
for line in self.segments:
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
|
||||||
|
import sys
|
||||||
from powerline.bindings.vim import vim_get_func, vim_getvar
|
from powerline.bindings.vim import vim_get_func, vim_getvar
|
||||||
from powerline import Powerline
|
from powerline import Powerline
|
||||||
from powerline.lib import mergedicts
|
from powerline.lib import mergedicts
|
||||||
@ -155,14 +156,27 @@ class VimPowerline(Powerline):
|
|||||||
__main__.__dict__)))
|
__main__.__dict__)))
|
||||||
|
|
||||||
|
|
||||||
|
pycmd = None
|
||||||
|
|
||||||
|
|
||||||
|
def set_pycmd(new_pycmd):
|
||||||
|
global pycmd
|
||||||
|
pycmd = new_pycmd
|
||||||
|
|
||||||
|
|
||||||
|
def get_default_pycmd():
|
||||||
|
return 'python' if sys.version_info < (3,) else 'python3'
|
||||||
|
|
||||||
|
|
||||||
def setup(pyeval=None, pycmd=None, can_replace_pyeval=True):
|
def setup(pyeval=None, pycmd=None, can_replace_pyeval=True):
|
||||||
import sys
|
|
||||||
import __main__
|
import __main__
|
||||||
if not pyeval:
|
if not pyeval:
|
||||||
pyeval = 'pyeval' if sys.version_info < (3,) else 'py3eval'
|
pyeval = 'pyeval' if sys.version_info < (3,) else 'py3eval'
|
||||||
can_replace_pyeval = True
|
can_replace_pyeval = True
|
||||||
if not pycmd:
|
if not pycmd:
|
||||||
pycmd = 'python' if sys.version_info < (3,) else 'python3'
|
pycmd = get_default_pycmd()
|
||||||
|
|
||||||
|
set_pycmd(pycmd)
|
||||||
|
|
||||||
# pyeval() and vim.bindeval were both introduced in one patch
|
# pyeval() and vim.bindeval were both introduced in one patch
|
||||||
if not hasattr(vim, 'bindeval') and can_replace_pyeval:
|
if not hasattr(vim, 'bindeval') and can_replace_pyeval:
|
||||||
|
@ -171,6 +171,16 @@ class TestLines(TestRender):
|
|||||||
], width=10)
|
], width=10)
|
||||||
|
|
||||||
|
|
||||||
|
class TestSegments(TestRender):
|
||||||
|
@add_p_arg
|
||||||
|
def test_display(self, p):
|
||||||
|
with replace_item(globals(), 'config', deepcopy(config)):
|
||||||
|
config['themes/test/default']['segments']['left'][0]['display'] = False
|
||||||
|
config['themes/test/default']['segments']['left'][1]['display'] = True
|
||||||
|
config['themes/test/default']['segments']['right'][0]['display'] = False
|
||||||
|
self.assertRenderEqual(p, '{344} g{4-}>>{--}')
|
||||||
|
|
||||||
|
|
||||||
class TestColorschemesHierarchy(TestRender):
|
class TestColorschemesHierarchy(TestRender):
|
||||||
@add_p_arg
|
@add_p_arg
|
||||||
def test_group_redirects(self, p):
|
def test_group_redirects(self, p):
|
||||||
|
@ -757,6 +757,26 @@ class TestVim(TestCase):
|
|||||||
with replace_attr(vim, 'guess', get_dummy_guess(status=lambda file: 'M')):
|
with replace_attr(vim, 'guess', get_dummy_guess(status=lambda file: 'M')):
|
||||||
self.assertEqual(file_vcs_status(segment_info=segment_info), None)
|
self.assertEqual(file_vcs_status(segment_info=segment_info), None)
|
||||||
|
|
||||||
|
def test_trailing_whitespace(self):
|
||||||
|
pl = Pl()
|
||||||
|
with vim_module._with('buffer', 'tws') as segment_info:
|
||||||
|
trailing_whitespace = partial(vim.trailing_whitespace, pl=pl, segment_info=segment_info)
|
||||||
|
self.assertEqual(trailing_whitespace(), None)
|
||||||
|
self.assertEqual(trailing_whitespace(), None)
|
||||||
|
vim_module.current.buffer[0] = ' '
|
||||||
|
self.assertEqual(trailing_whitespace(), [{
|
||||||
|
'highlight_group': ['trailing_whitespace', 'warning'],
|
||||||
|
'contents': '1',
|
||||||
|
}])
|
||||||
|
self.assertEqual(trailing_whitespace(), [{
|
||||||
|
'highlight_group': ['trailing_whitespace', 'warning'],
|
||||||
|
'contents': '1',
|
||||||
|
}])
|
||||||
|
vim_module.current.buffer[0] = ''
|
||||||
|
self.assertEqual(trailing_whitespace(), None)
|
||||||
|
self.assertEqual(trailing_whitespace(), None)
|
||||||
|
|
||||||
|
|
||||||
old_cwd = None
|
old_cwd = None
|
||||||
|
|
||||||
|
|
||||||
|
50
tests/vim.py
50
tests/vim.py
@ -167,8 +167,14 @@ def _log_print():
|
|||||||
sys.stdout.write(repr(entry) + '\n')
|
sys.stdout.write(repr(entry) + '\n')
|
||||||
|
|
||||||
|
|
||||||
|
_current_group = None
|
||||||
|
_on_wipeout = []
|
||||||
|
|
||||||
|
|
||||||
@_vim
|
@_vim
|
||||||
def command(cmd):
|
def command(cmd):
|
||||||
|
global _current_group
|
||||||
|
cmd = cmd.lstrip()
|
||||||
if cmd.startswith('let g:'):
|
if cmd.startswith('let g:'):
|
||||||
import re
|
import re
|
||||||
varname, value = re.compile(r'^let g:(\w+)\s*=\s*(.*)').match(cmd).groups()
|
varname, value = re.compile(r'^let g:(\w+)\s*=\s*(.*)').match(cmd).groups()
|
||||||
@ -179,6 +185,26 @@ def command(cmd):
|
|||||||
elif cmd.startswith('function! Powerline_plugin_ctrlp'):
|
elif cmd.startswith('function! Powerline_plugin_ctrlp'):
|
||||||
# Ignore CtrlP updating functions
|
# Ignore CtrlP updating functions
|
||||||
pass
|
pass
|
||||||
|
elif cmd.startswith('augroup'):
|
||||||
|
augroup = cmd.partition(' ')[2]
|
||||||
|
if augroup.upper() == 'END':
|
||||||
|
_current_group = None
|
||||||
|
else:
|
||||||
|
_current_group = augroup
|
||||||
|
elif cmd.startswith('autocmd'):
|
||||||
|
rest = cmd.partition(' ')[2]
|
||||||
|
auevent, rest = rest.partition(' ')[::2]
|
||||||
|
pattern, aucmd = rest.partition(' ')[::2]
|
||||||
|
if auevent != 'BufWipeout' or pattern != '*':
|
||||||
|
raise NotImplementedError
|
||||||
|
import sys
|
||||||
|
if sys.version_info < (3,):
|
||||||
|
if not aucmd.startswith(':python '):
|
||||||
|
raise NotImplementedError
|
||||||
|
else:
|
||||||
|
if not aucmd.startswith(':python3 '):
|
||||||
|
raise NotImplementedError
|
||||||
|
_on_wipeout.append(aucmd.partition(' ')[2])
|
||||||
else:
|
else:
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
@ -314,8 +340,9 @@ def _emul_fnamemodify(path, modstring):
|
|||||||
@_vim
|
@_vim
|
||||||
@_str_func
|
@_str_func
|
||||||
def _emul_expand(expr):
|
def _emul_expand(expr):
|
||||||
|
global _abuf
|
||||||
if expr == '<abuf>':
|
if expr == '<abuf>':
|
||||||
return _buffer()
|
return _abuf or _buffer()
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
|
||||||
@ -398,6 +425,7 @@ class _Window(object):
|
|||||||
_buf_lines = {}
|
_buf_lines = {}
|
||||||
_undostate = {}
|
_undostate = {}
|
||||||
_undo_written = {}
|
_undo_written = {}
|
||||||
|
_abuf = None
|
||||||
|
|
||||||
|
|
||||||
class _Buffer(object):
|
class _Buffer(object):
|
||||||
@ -408,7 +436,7 @@ class _Buffer(object):
|
|||||||
self.number = bufnr
|
self.number = bufnr
|
||||||
# FIXME Use unicode() for python-3
|
# FIXME Use unicode() for python-3
|
||||||
self.name = name
|
self.name = name
|
||||||
self.vars = {}
|
self.vars = {'changedtick': 1}
|
||||||
self.options = {
|
self.options = {
|
||||||
'modified': 0,
|
'modified': 0,
|
||||||
'readonly': 0,
|
'readonly': 0,
|
||||||
@ -447,12 +475,14 @@ class _Buffer(object):
|
|||||||
|
|
||||||
def __setitem__(self, line, value):
|
def __setitem__(self, line, value):
|
||||||
self.options['modified'] = 1
|
self.options['modified'] = 1
|
||||||
|
self.vars['changedtick'] += 1
|
||||||
_buf_lines[self.number][line] = value
|
_buf_lines[self.number][line] = value
|
||||||
from copy import copy
|
from copy import copy
|
||||||
_undostate[self.number].append(copy(_buf_lines[self.number]))
|
_undostate[self.number].append(copy(_buf_lines[self.number]))
|
||||||
|
|
||||||
def __setslice__(self, *args):
|
def __setslice__(self, *args):
|
||||||
self.options['modified'] = 1
|
self.options['modified'] = 1
|
||||||
|
self.vars['changedtick'] += 1
|
||||||
_buf_lines[self.number].__setslice__(*args)
|
_buf_lines[self.number].__setslice__(*args)
|
||||||
from copy import copy
|
from copy import copy
|
||||||
_undostate[self.number].append(copy(_buf_lines[self.number]))
|
_undostate[self.number].append(copy(_buf_lines[self.number]))
|
||||||
@ -467,7 +497,23 @@ class _Buffer(object):
|
|||||||
return '<buffer ' + str(self.name) + '>'
|
return '<buffer ' + str(self.name) + '>'
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
|
global _abuf
|
||||||
bufnr = self.number
|
bufnr = self.number
|
||||||
|
try:
|
||||||
|
import __main__
|
||||||
|
except ImportError:
|
||||||
|
pass
|
||||||
|
except RuntimeError:
|
||||||
|
# Module may have already been garbage-collected
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
if _on_wipeout:
|
||||||
|
_abuf = bufnr
|
||||||
|
try:
|
||||||
|
for event in _on_wipeout:
|
||||||
|
exec(event, __main__.__dict__)
|
||||||
|
finally:
|
||||||
|
_abuf = None
|
||||||
if _buf_lines:
|
if _buf_lines:
|
||||||
_buf_lines.pop(bufnr)
|
_buf_lines.pop(bufnr)
|
||||||
if _undostate:
|
if _undostate:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user