Merge pull request #348 from cwahbong/select-cr-fix
Fix issue #341 (github).
This commit is contained in:
commit
57ed954ccd
@ -379,15 +379,23 @@ class SnippetManager(object):
|
|||||||
def _jump(self, backwards=False):
|
def _jump(self, backwards=False):
|
||||||
"""Helper method that does the actual jump."""
|
"""Helper method that does the actual jump."""
|
||||||
jumped = False
|
jumped = False
|
||||||
|
# If next tab has length 1 and the distance between itself and
|
||||||
|
# self._ctab is 1 then there is 1 less CursorMove events. We
|
||||||
|
# cannot ignore next movement in such case.
|
||||||
|
ntab_short_and_near = False
|
||||||
if self._cs:
|
if self._cs:
|
||||||
self._ctab = self._cs.select_next_tab(backwards)
|
ntab = self._cs.select_next_tab(backwards)
|
||||||
if self._ctab:
|
if ntab:
|
||||||
if self._cs.snippet.has_option("s"):
|
if self._cs.snippet.has_option("s"):
|
||||||
lineno = _vim.buf.cursor.line
|
lineno = _vim.buf.cursor.line
|
||||||
_vim.buf[lineno] = _vim.buf[lineno].rstrip()
|
_vim.buf[lineno] = _vim.buf[lineno].rstrip()
|
||||||
_vim.select(self._ctab.start, self._ctab.end)
|
_vim.select(ntab.start, ntab.end)
|
||||||
jumped = True
|
jumped = True
|
||||||
if self._ctab.number == 0:
|
if (self._ctab is not None
|
||||||
|
and ntab.start - self._ctab.end == Position(0, 1)
|
||||||
|
and ntab.end - ntab.start == Position(0, 1)):
|
||||||
|
ntab_short_and_near = True
|
||||||
|
if ntab.number == 0:
|
||||||
self._current_snippet_is_done()
|
self._current_snippet_is_done()
|
||||||
else:
|
else:
|
||||||
# This really shouldn't happen, because a snippet should
|
# This really shouldn't happen, because a snippet should
|
||||||
@ -395,10 +403,12 @@ class SnippetManager(object):
|
|||||||
# Cleanup by removing current snippet and recursing.
|
# Cleanup by removing current snippet and recursing.
|
||||||
self._current_snippet_is_done()
|
self._current_snippet_is_done()
|
||||||
jumped = self._jump(backwards)
|
jumped = self._jump(backwards)
|
||||||
|
self._ctab = ntab
|
||||||
if jumped:
|
if jumped:
|
||||||
self._vstate.remember_position()
|
self._vstate.remember_position()
|
||||||
self._vstate.remember_unnamed_register(self._ctab.current_text)
|
self._vstate.remember_unnamed_register(self._ctab.current_text)
|
||||||
self._ignore_movements = True
|
if not ntab_short_and_near:
|
||||||
|
self._ignore_movements = True
|
||||||
return jumped
|
return jumped
|
||||||
|
|
||||||
def _leaving_insert_mode(self):
|
def _leaving_insert_mode(self):
|
||||||
@ -506,7 +516,6 @@ class SnippetManager(object):
|
|||||||
|
|
||||||
si.update_textobjects()
|
si.update_textobjects()
|
||||||
|
|
||||||
self._ignore_movements = True
|
|
||||||
self._vstate.remember_buffer(self._csnippets[0])
|
self._vstate.remember_buffer(self._csnippets[0])
|
||||||
|
|
||||||
self._jump()
|
self._jump()
|
||||||
|
@ -251,3 +251,8 @@ class TabStopNavigatingInInsertModeSimple_ExpectCorrectResult(_VimTest):
|
|||||||
snippets = ("hallo", "Hallo ${1:WELT} ups")
|
snippets = ("hallo", "Hallo ${1:WELT} ups")
|
||||||
keys = "hallo" + EX + "haselnut" + 2*ARR_L + "hips" + JF + "end"
|
keys = "hallo" + EX + "haselnut" + 2*ARR_L + "hips" + JF + "end"
|
||||||
wanted = "Hallo haselnhipsut upsend"
|
wanted = "Hallo haselnhipsut upsend"
|
||||||
|
|
||||||
|
class TabStop_CROnlyOnSelectedNear(_VimTest):
|
||||||
|
snippets = ("test", "t$1t${2: }t{\n\t$0\n}")
|
||||||
|
keys = "test" + EX + JF + "\n" + JF + "t"
|
||||||
|
wanted = "tt\nt{\n\tt\n}"
|
||||||
|
Loading…
Reference in New Issue
Block a user