From 57cf2790cbe7fa8c62166406a2f2e1fdd72a157b Mon Sep 17 00:00:00 2001 From: Holger Rapp Date: Sun, 20 Feb 2011 21:16:56 +0100 Subject: [PATCH] Refactored fix for better understandability --- plugin/UltiSnips/__init__.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugin/UltiSnips/__init__.py b/plugin/UltiSnips/__init__.py index fdc9dc9..9709a90 100644 --- a/plugin/UltiSnips/__init__.py +++ b/plugin/UltiSnips/__init__.py @@ -694,8 +694,12 @@ class SnippetManager(object): this_entered = vim.current.line[:self._vstate.pos.col] self._chars_entered('\n' + cline + this_entered, 1) if line_was_shortened and user_didnt_enter_newline: - self._backspace(self._vstate.ppos.col-len(lline)) - self._chars_entered('\n' + cline[:len(cline)-(len(self._vstate.last_line)-self._vstate.ppos.col)], 1) + nchars_deleted_in_lline = self._vstate.ppos.col - len(lline) + self._backspace(nchars_deleted_in_lline) + nchars_wrapped_from_lline_after_cursor = \ + len(self._vstate.last_line) - self._vstate.ppos.col + self._chars_entered('\n' + cline + [:len(cline)-nchars_wrapped_from_lline_after_cursor], 1) else: pentered = lline[self._vstate.ppos.col:] this_entered = vim.current.line[:self._vstate.pos.col]