Retains the unnamed register during jumps

This commit is contained in:
LFDM 2014-01-31 16:18:14 +01:00
parent ae611ccf95
commit fee8a23d2d

View File

@ -553,8 +553,13 @@ class SnippetManager(object):
self._supertab_keys = None
self._csnippets = []
# needed to retain the unnamed register at all times
self._unnamed_reg_cached = False
self._last_placeholder = None
self.reset()
@err_to_scratch_buffer
def reset(self, test_error=False):
self._vstate = VimState()
@ -832,10 +837,23 @@ class SnippetManager(object):
self._current_snippet_is_done()
jumped = self._jump(backwards)
if jumped:
self._cache_unnamed_register()
self._vstate.remember_position()
self._ignore_movements = True
return jumped
def _cache_unnamed_register(self):
self._unnamed_reg_cached = True
unnamed_reg = _vim.eval('@"')
if self._last_placeholder != unnamed_reg:
self._unnamed_reg_cache = _vim.eval('@"')
self._last_placeholder = self._ctab._initial_text
def restore_unnamed_register(self):
if self._unnamed_reg_cached:
_vim.command( "let @\"='%s'" % self._unnamed_reg_cache)
self._unnamed_register_cached = False
def _handle_failure(self, trigger):
"""
Mainly make sure that we play well with SuperTab