forked from VimPlug/jedi
Fast parser fix.
This commit is contained in:
+4
-5
@@ -478,15 +478,15 @@ class FastTokenizer(object):
|
|||||||
|
|
||||||
if typ == INDENT:
|
if typ == INDENT:
|
||||||
self._indent_counter += 1
|
self._indent_counter += 1
|
||||||
if not self._expect_indent and not self._first_stmt:
|
if not self._expect_indent and not self._first_stmt and not self._in_flow:
|
||||||
# This does not mean that there is an actual flow, but it means
|
# This does not mean that there is an actual flow, it means
|
||||||
# that the INDENT is either syntactically wrong or a flow.
|
# that the INDENT is syntactically wrong.
|
||||||
|
self._flow_indent_counter = self._indent_counter - 1
|
||||||
self._in_flow = True
|
self._in_flow = True
|
||||||
self._expect_indent = False
|
self._expect_indent = False
|
||||||
elif typ == DEDENT:
|
elif typ == DEDENT:
|
||||||
self._indent_counter -= 1
|
self._indent_counter -= 1
|
||||||
if self._in_flow:
|
if self._in_flow:
|
||||||
# TODO add <= for flows without INDENT in classes.
|
|
||||||
if self._indent_counter == self._flow_indent_counter:
|
if self._indent_counter == self._flow_indent_counter:
|
||||||
self._in_flow = False
|
self._in_flow = False
|
||||||
else:
|
else:
|
||||||
@@ -507,7 +507,6 @@ class FastTokenizer(object):
|
|||||||
# new lines.
|
# new lines.
|
||||||
if self.previous[0] in (NEWLINE, INDENT, DEDENT) \
|
if self.previous[0] in (NEWLINE, INDENT, DEDENT) \
|
||||||
and not self._parentheses_level and typ not in (INDENT, DEDENT):
|
and not self._parentheses_level and typ not in (INDENT, DEDENT):
|
||||||
# Check for NEWLINE, which symbolizes the indent.
|
|
||||||
if not self._in_flow:
|
if not self._in_flow:
|
||||||
if value in FLOWS:
|
if value in FLOWS:
|
||||||
self._flow_indent_counter = self._indent_counter
|
self._flow_indent_counter = self._indent_counter
|
||||||
|
|||||||
@@ -322,6 +322,18 @@ def test_wrong_indentation():
|
|||||||
""")
|
""")
|
||||||
check_fp(src, 1)
|
check_fp(src, 1)
|
||||||
|
|
||||||
|
src = dedent("""\
|
||||||
|
def complex():
|
||||||
|
def nested():
|
||||||
|
a
|
||||||
|
b
|
||||||
|
a
|
||||||
|
|
||||||
|
def other():
|
||||||
|
pass
|
||||||
|
""")
|
||||||
|
check_fp(src, 3)
|
||||||
|
|
||||||
|
|
||||||
def test_open_parentheses():
|
def test_open_parentheses():
|
||||||
func = 'def func():\n a'
|
func = 'def func():\n a'
|
||||||
|
|||||||
Reference in New Issue
Block a user