If a snippet doesn't define a zero Tabstop, it is now automatically added at it's end after parsing

This commit is contained in:
Holger Rapp 2009-07-09 08:10:46 +02:00
parent 448a0a30b9
commit 920f6f6dbe
2 changed files with 15 additions and 10 deletions

View File

@ -390,6 +390,21 @@ class SnippetInstance(TextObject):
TextObject.update(self, self._vb)
# Check if we have a zero Tab, if not, add one at the end
if 0 not in self._tabstops:
delta = self._end - self._start
col = self.end.col
if delta.line == 0:
col -= self.start.col
start = Position(delta.line, col)
end = Position(delta.line, col)
debug("Adding zero Tabstop!")
debug("start: %s, end: %s" % (start, end))
ts = TabStop(self, start, end, "")
self.add_tabstop(0,ts)
TextObject.update(self, self._vb)
def tab_selected(self):
return self._tab_selected
tab_selected = property(tab_selected)

View File

@ -238,16 +238,6 @@ class SnippetManager(object):
self._expect_move_wo_change = True
ts = self._csnippet.select_next_tab(backwards)
if ts is None:
# HACK: only jump to end if there is no zero defined. This
# TODO: this jump should be inside select_next_tab or even
# better: when the snippet is launched and no parent snippet is
# defined, a $0 should be appended to the end of it and this
# extra code should be ignored Jump to the end of the snippet
# and enter insert mode
if 0 not in self._csnippet._tabstops:
vim.current.window.cursor = self._csnippet.end.line +1, \
self._csnippet.end.col
vim.command(r'call feedkeys("\<Esc>a")')
self._csnippet = None
return True