diff --git a/plugin/PySnipEmu/TextObjects.py b/plugin/PySnipEmu/TextObjects.py index 11a5937..d5e0acb 100644 --- a/plugin/PySnipEmu/TextObjects.py +++ b/plugin/PySnipEmu/TextObjects.py @@ -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) diff --git a/plugin/PySnipEmu/__init__.py b/plugin/PySnipEmu/__init__.py index 6fd0f1d..71b1353 100644 --- a/plugin/PySnipEmu/__init__.py +++ b/plugin/PySnipEmu/__init__.py @@ -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("\a")') self._csnippet = None return True