This commit is contained in:
Anthony Scopatz 2015-03-31 11:02:36 -05:00
parent 8074280dc6
commit 41e863f330
2 changed files with 10 additions and 1 deletions

View file

@ -68,6 +68,12 @@ def test_subproc_toks_indent_ls_no_min_nl():
obs = subproc_toks(INDENT + s + '\n', lexer=LEXER, returnline=True)
assert_equal(exp, obs)
def test_subproc_toks_indent_ls_no_min_semi():
s = 'ls'
exp = INDENT + '$[{0}];'.format(s)
obs = subproc_toks(INDENT + s + ';', lexer=LEXER, returnline=True)
assert_equal(exp, obs)
def test_subproc_toks_ls_comment():
s = 'ls -l'
com = ' # lets list'

View file

@ -51,7 +51,8 @@ def subproc_toks(line, mincol=-1, maxcol=None, lexer=None, returnline=False):
break
if len(toks) == 0 and tok.type in ('WS', 'INDENT'):
continue # handle indentation
elif len(toks) > 0 and toks[-1].type == 'SEMI':
elif len(toks) > 0 and toks[-1].type == 'SEMI' and pos < maxcol and \
tok.type not in ('NEWLINE', 'DEDENT', 'WS'):
toks.clear()
if pos < mincol:
continue
@ -77,6 +78,8 @@ def subproc_toks(line, mincol=-1, maxcol=None, lexer=None, returnline=False):
else:
el = line[pos:].split('#')[0].rstrip()
end_offset = len(el)
if toks[-1].type == 'SEMI':
toks.pop()
if len(toks) == 0:
return # handle comment lines
beg, end = toks[0].lexpos, (toks[-1].lexpos + end_offset)