From bf017ac7ea738e28eeae4dd9f5c201805011431c Mon Sep 17 00:00:00 2001 From: Holger Rapp Date: Wed, 1 Jul 2009 23:09:20 +0200 Subject: [PATCH] Some more minor refactoring. --- PySnipEmu.py | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/PySnipEmu.py b/PySnipEmu.py index 9bcdf42..0b2af01 100644 --- a/PySnipEmu.py +++ b/PySnipEmu.py @@ -102,13 +102,10 @@ class TabStop(TextObject): lineno, col = start newline = lineno + self._start[0] - # TODO: remove span + newcol = self._start[1] + self._delta_cols + if newline == lineno: - newcol = col + self.span[0] - endcol = col + self.span[1] - else: - newcol = self.span[0] - endcol = self.span[1] + newcol += col vim.current.window.cursor = newline, newcol @@ -116,20 +113,16 @@ class TabStop(TextObject): # Depending on the current mode and position, we # might need to move escape out of the mode and this # will move our cursor one left - if endcol-newcol > 0: + if len(self._ct) > 0: if newcol != 0 and vim.eval("mode()") == 'i': move_one_right = "l" else: move_one_right = "" vim.command(r'call feedkeys("\%sv%il\")' - % (move_one_right, endcol-newcol-1)) + % (move_one_right, len(self._ct)-1)) - @property - def span(self): - return (self._start[1]+self._delta_cols,self._start[1]+self._delta_cols+len(self._ct)) - class SnippetInstance(TextObject): """ A Snippet instance is an instance of a Snippet Definition. That is, @@ -256,7 +249,8 @@ class Snippet(object): line_idx = val[:start].count('\n') line_start = val[:start].rfind('\n') + 1 start_in_line = start - line_start - ts = TabStop(line_idx, (start_in_line,start_in_line+len(def_text)), def_text) + ts = TabStop(line_idx, (start_in_line,start_in_line+len(def_text)), + def_text) tabstops[no] = ts