Fix line numbers in python error warnings and make all.snippets work for lua too. Fixes #211.
This commit is contained in:
parent
e7868dd4fb
commit
7ef866e1f4
@ -22,7 +22,6 @@ def _parse_comments(s):
|
||||
flags, text = next(i).split(':', 1)
|
||||
|
||||
if len(flags) == 0:
|
||||
if len(text) == 1:
|
||||
rv.append((text, text, text, ""))
|
||||
# parse 3-part comment, but ignore those with O flag
|
||||
elif flags[0] == 's' and 'O' not in flags:
|
||||
@ -43,38 +42,26 @@ def _parse_comments(s):
|
||||
ctriple.append(indent)
|
||||
|
||||
rv.append(ctriple)
|
||||
|
||||
elif flags[0] == 'b':
|
||||
if len(text) == 1:
|
||||
rv.insert(0, (text,text,text, ""))
|
||||
|
||||
except StopIteration:
|
||||
return rv
|
||||
|
||||
def _get_comment_format():
|
||||
""" Returns a 4-element tuple representing the comment format for
|
||||
the current file. """
|
||||
|
||||
ft = vim.eval("&filetype")
|
||||
# check if the comment dict has the format for the current file
|
||||
if ft in _commentDict:
|
||||
return _commentDict[ft]
|
||||
|
||||
# otherwise parse vim's comments and add it for later use
|
||||
commentformat = _parse_comments(vim.eval("&comments"))[0]
|
||||
_commentDict[ft] = commentformat
|
||||
|
||||
return commentformat
|
||||
return _parse_comments(vim.eval("&comments"))[0]
|
||||
|
||||
|
||||
def make_box(twidth, bwidth=None):
|
||||
b, m, e, i = _get_comment_format()
|
||||
bwidth_inner = bwidth - 3 - max(len(b), len(i + e)) if bwidth else twidth + 2
|
||||
sline = b + m + bwidth_inner * m + 2 * m
|
||||
sline = b + m + bwidth_inner * m[0] + 2 * m[0]
|
||||
nspaces = (bwidth_inner - twidth) // 2
|
||||
mlines = i + m + " " + " " * nspaces
|
||||
mlinee = " " + " "*(bwidth_inner - twidth - nspaces) + m
|
||||
eline = i + 2 * m + bwidth_inner * m + m + e
|
||||
eline = i + m + bwidth_inner * m[0] + 2 * m[0] + e
|
||||
return sline, mlines, mlinee, eline
|
||||
|
||||
def foldmarker():
|
||||
|
@ -175,7 +175,7 @@ class PythonCode(NoneditableTextObject):
|
||||
snippet = snippet._parent # pylint:disable=protected-access
|
||||
self._snip = SnippetUtil(token.indent, mode, text)
|
||||
|
||||
self._code = "\n".join((
|
||||
self._codes = ((
|
||||
"import re, os, vim, string, random",
|
||||
"\n".join(snippet.globals.get("!p", [])).replace("\r\n", "\n"),
|
||||
token.code.replace("\\`", "`")
|
||||
@ -195,7 +195,8 @@ class PythonCode(NoneditableTextObject):
|
||||
})
|
||||
self._snip._reset(ct) # pylint:disable=protected-access
|
||||
|
||||
exec(self._code, self._locals) # pylint:disable=exec-used
|
||||
for code in self._codes:
|
||||
exec(code, self._locals) # pylint:disable=exec-used
|
||||
|
||||
rv = as_unicode(
|
||||
self._snip.rv if self._snip._rv_changed # pylint:disable=protected-access
|
||||
|
Loading…
Reference in New Issue
Block a user