From d49db703e590e96e2433c31bf5a71feb82ab4cf7 Mon Sep 17 00:00:00 2001 From: Holger Rapp Date: Sat, 24 Mar 2012 20:15:43 +0100 Subject: [PATCH] Fixed bug with mkline and noexpandtab --- plugin/UltiSnips/util.py | 14 +------------- test.py | 18 +++++++++--------- 2 files changed, 10 insertions(+), 22 deletions(-) diff --git a/plugin/UltiSnips/util.py b/plugin/UltiSnips/util.py index 8582916..bb1bef2 100644 --- a/plugin/UltiSnips/util.py +++ b/plugin/UltiSnips/util.py @@ -19,18 +19,6 @@ class IndentUtil(object): self.et = (_vim.eval("&expandtab") == "1") self.ts = int(_vim.eval("&ts")) - # The amount added when pressing tab in insert mode - self.ind_len = self.sts or self.ts - - def _strip_tabs(self, indent, ts): - new_ind = [] - for ch in indent: - if ch == '\t': - new_ind.append(" " * (ts - (len(new_ind) % ts))) - else: - new_ind.append(ch) - return "".join(new_ind) - def ntabs_to_proper_indent(self, ntabs): line_ind = ntabs * self.sw * " " line_ind = self.indent_to_spaces(line_ind) @@ -39,7 +27,7 @@ class IndentUtil(object): def indent_to_spaces(self, indent): """ Converts indentation to spaces respecting Vim settings. """ - indent = self._strip_tabs(indent, self.ts) + indent = indent.expandtabs(self.ts) right = (len(indent) - len(indent.rstrip(" "))) * " " indent = indent.replace(" ", "") indent = indent.replace('\t', " " * self.ts) diff --git a/test.py b/test.py index dd40673..fcb4aeb 100755 --- a/test.py +++ b/test.py @@ -2104,15 +2104,15 @@ class No_Tab_Expand_RealWorld(_TabExpand_RealWorld,_VimTest): self.send(":set noexpandtab\n") def _options_off(self): self.send(":set noexpandtab\n") - keys = "\t\t\thi" + EX - wanted = """\t\t\thi -\t\t\ti1 -\t\t\ti1 -\t\t\t\ti2 -\t\ti0 -\t\t\t\t\ti3 -\t\t\tsnip.rv = repr(snip.rv) -\t\t\tEnd""" + keys = "\t\thi" + EX + wanted = """\t\thi +\t\ti1 +\t\ti1 +\t\t\ti2 +\ti0 +\t\t\t\ti3 +\t\tsnip.rv = repr(snip.rv) +\t\tEnd""" class SnippetOptions_Regex_Expand(_VimTest):