Merge branch 'retaining_the_unnamed_register' of git://github.com/LFDM/ultisnips into LFDM-retaining_the_unnamed_register
This commit is contained in:
commit
3e03e38dbc
@ -227,6 +227,11 @@ endf
|
|||||||
function! UltiSnips_LeavingBuffer()
|
function! UltiSnips_LeavingBuffer()
|
||||||
exec g:_uspy "UltiSnips_Manager.leaving_buffer()"
|
exec g:_uspy "UltiSnips_Manager.leaving_buffer()"
|
||||||
endf
|
endf
|
||||||
|
|
||||||
|
function! UltiSnips_LeavingInsertMode()
|
||||||
|
exec g:_uspy "UltiSnips_Manager.restore_unnamed_register()"
|
||||||
|
endfunction
|
||||||
|
|
||||||
" }}}
|
" }}}
|
||||||
" COMPLETE FUNCTIONS {{{
|
" COMPLETE FUNCTIONS {{{
|
||||||
function! UltiSnipsFiletypeComplete(arglead, cmdline, cursorpos)
|
function! UltiSnipsFiletypeComplete(arglead, cmdline, cursorpos)
|
||||||
@ -262,6 +267,7 @@ exec g:_uspy "UltiSnips_Manager.backward_trigger = vim.eval('g:UltiSnipsJumpBack
|
|||||||
au CursorMovedI * call UltiSnips_CursorMoved()
|
au CursorMovedI * call UltiSnips_CursorMoved()
|
||||||
au CursorMoved * call UltiSnips_CursorMoved()
|
au CursorMoved * call UltiSnips_CursorMoved()
|
||||||
au BufLeave * call UltiSnips_LeavingBuffer()
|
au BufLeave * call UltiSnips_LeavingBuffer()
|
||||||
|
au InsertLeave * call UltiSnips_LeavingInsertMode()
|
||||||
|
|
||||||
call UltiSnips_MapKeys()
|
call UltiSnips_MapKeys()
|
||||||
|
|
||||||
|
@ -553,8 +553,13 @@ class SnippetManager(object):
|
|||||||
self._supertab_keys = None
|
self._supertab_keys = None
|
||||||
self._csnippets = []
|
self._csnippets = []
|
||||||
|
|
||||||
|
# needed to retain the unnamed register at all times
|
||||||
|
self._unnamed_reg_cached = False
|
||||||
|
self._last_placeholder = None
|
||||||
|
|
||||||
self.reset()
|
self.reset()
|
||||||
|
|
||||||
|
|
||||||
@err_to_scratch_buffer
|
@err_to_scratch_buffer
|
||||||
def reset(self, test_error=False):
|
def reset(self, test_error=False):
|
||||||
self._vstate = VimState()
|
self._vstate = VimState()
|
||||||
@ -832,10 +837,24 @@ class SnippetManager(object):
|
|||||||
self._current_snippet_is_done()
|
self._current_snippet_is_done()
|
||||||
jumped = self._jump(backwards)
|
jumped = self._jump(backwards)
|
||||||
if jumped:
|
if jumped:
|
||||||
|
self._cache_unnamed_register()
|
||||||
self._vstate.remember_position()
|
self._vstate.remember_position()
|
||||||
self._ignore_movements = True
|
self._ignore_movements = True
|
||||||
return jumped
|
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 = unnamed_reg
|
||||||
|
self._last_placeholder = self._ctab._initial_text
|
||||||
|
|
||||||
|
def restore_unnamed_register(self):
|
||||||
|
if self._unnamed_reg_cached:
|
||||||
|
escaped_cache = self._unnamed_reg_cache.replace("'", "''")
|
||||||
|
_vim.command("let @\"='%s'" % escaped_cache)
|
||||||
|
self._unnamed_register_cached = False
|
||||||
|
|
||||||
def _handle_failure(self, trigger):
|
def _handle_failure(self, trigger):
|
||||||
"""
|
"""
|
||||||
Mainly make sure that we play well with SuperTab
|
Mainly make sure that we play well with SuperTab
|
||||||
|
7
test.py
7
test.py
@ -3041,6 +3041,13 @@ class Bug1251994(_VimTest):
|
|||||||
wanted = " world hello;blub"
|
wanted = " world hello;blub"
|
||||||
# End: 1251994 #}}}
|
# End: 1251994 #}}}
|
||||||
|
|
||||||
|
# Test for Github Pull Request #134 {{{#
|
||||||
|
class RetainsTheUnnamedRegister(_VimTest):
|
||||||
|
snippets = ("test", "${1:hello} ${2:world} ${0}")
|
||||||
|
keys = "yank" + ESC + "by4lea test" + EX + "HELLO" + JF + JF + ESC + "p"
|
||||||
|
wanted = "yank HELLO world yank"
|
||||||
|
# End: Github Pull Request # 134 #}}}
|
||||||
|
|
||||||
class VerifyVimDict1(_VimTest):
|
class VerifyVimDict1(_VimTest):
|
||||||
"""check:
|
"""check:
|
||||||
correct type (4 means vim dictionary)
|
correct type (4 means vim dictionary)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user