Fixed bug with mkline and noexpandtab

This commit is contained in:
Holger Rapp 2012-03-24 20:15:43 +01:00
parent 4be8a92bf6
commit d49db703e5
2 changed files with 10 additions and 22 deletions

View File

@ -19,18 +19,6 @@ class IndentUtil(object):
self.et = (_vim.eval("&expandtab") == "1") self.et = (_vim.eval("&expandtab") == "1")
self.ts = int(_vim.eval("&ts")) 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): def ntabs_to_proper_indent(self, ntabs):
line_ind = ntabs * self.sw * " " line_ind = ntabs * self.sw * " "
line_ind = self.indent_to_spaces(line_ind) line_ind = self.indent_to_spaces(line_ind)
@ -39,7 +27,7 @@ class IndentUtil(object):
def indent_to_spaces(self, indent): def indent_to_spaces(self, indent):
""" Converts indentation to spaces respecting Vim settings. """ """ 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(" "))) * " " right = (len(indent) - len(indent.rstrip(" "))) * " "
indent = indent.replace(" ", "") indent = indent.replace(" ", "")
indent = indent.replace('\t', " " * self.ts) indent = indent.replace('\t', " " * self.ts)

18
test.py
View File

@ -2104,15 +2104,15 @@ class No_Tab_Expand_RealWorld(_TabExpand_RealWorld,_VimTest):
self.send(":set noexpandtab\n") self.send(":set noexpandtab\n")
def _options_off(self): def _options_off(self):
self.send(":set noexpandtab\n") self.send(":set noexpandtab\n")
keys = "\t\t\thi" + EX keys = "\t\thi" + EX
wanted = """\t\t\thi wanted = """\t\thi
\t\t\ti1 \t\ti1
\t\t\ti1 \t\ti1
\t\t\t\ti2 \t\t\ti2
\t\ti0 \ti0
\t\t\t\t\ti3 \t\t\t\ti3
\t\t\tsnip.rv = repr(snip.rv) \t\tsnip.rv = repr(snip.rv)
\t\t\tEnd""" \t\tEnd"""
class SnippetOptions_Regex_Expand(_VimTest): class SnippetOptions_Regex_Expand(_VimTest):